During the development process many migrations may appear. Is there any point to keep them instead of merging them all together?
Let's take a look into a simple example.
During development we introduce a new model Person
:
public class Person {
public int Id { get; set; }
public string Name { get; set; }
}
Migration #1 creates a new table Persons
with two fields in the database.
Later we decided we need another field - Surname
. Migration #2 alters table by adding a new field.
Later we decided to introduce a new related model, so Migration #3 creates new table and alters Persons
by adding foreign key.
Later we decided to remove Surname
. Migration #4 alters table by removing column.
Later we decided to rename plural form of Persons
to Person
. Migration #5 removes all foreign keys, laters table by renaming it, creates new foreign keys.
In the end we have a bunch of migrations doing back'n'forth work of creating and removing some fields that we don't need in the final release. Those fields among with some other possible migrations actions are just a part of the history of development, but we don't really need them.
So I was thinking what if I roll back the database to the very first state, remove all migrations and then generate a new one, which will do only nessesary actions to bring a database to it's final state, reducing a possibly huge number of migrations and exessive actions to just one straight forward migration.
Is it a good idea or it is considered an anti-pattern?