Reputation: 8609
I am trying to delete migration but that results into some weird scenario.
To create this migrations I:
As a result of that new table created and everything worked as expected. Until I decided that I don't need that table any more (but at that point I already create some of other migrations - so migration that I am trying to delete is not last) so I:
And I got an error: Unable to update database to match the current model because there are pending changes and automatic migration is disabled.
In order to find out what exactly is pending I tried to add new migration and that new migration in it's Up
method deletes that table that no longer exists and creates that table in Down
method (exactly opposite what original migration done).
I even tried to delete my database and generate that from scratch, but no success - getting into the same state.
I tried to experiment with that found odd behaviour:
Down
) - nothing happens - table isn't createdSo how can I completely get rid of that class and migration?
Upvotes: 2
Views: 1621
Reputation: 73
You have two options here.
The first is to just add an additional migration to delete the table. This is the easiest and probably the "best practice" route (especially if migration is already in production). Only downside is that you would have 2 migrations that would just be used to cancel each other out. But that isn't necessarily a bad thing. To do this:
If you want to limit the number of migrations for some reason, you would need to do the following:
Happy Coding.
Upvotes: 2