In the process of learning south I've made some mistakes which I'd like to recitfy. Here's one of them:
# migrate --list
(*) 0002_auto__add_lesson #add the table
(*) 0003_auto__del_lesson #dammit, table uses wrong db engine so delete it
(*) 0004_auto__add_lesson #recreate the table
Clearly, I can just run step 4 and 2 and 3 won't be applied if they're starred:
./migrate my_app 0004
But as step 2 and 3 are redundant and don't need to be run, is it possible to simply remove them? Also, I should add Im worried someone might just run migrate which would then delete the table (and any data) and then recreate it...
Thanks in advance,
There are two considerations here.
First, if you have already run a migration, then it's recorded in database and if you just remove a file than you will run into problems: your database will refer to non-existent migration. There is a solution: run migrations 2 and 3 backwards with ./manage.py migrate my_app 0001
, then delete migration files. If you can't migrate back (e.g. you messed up with your database manually) then you can fake migrate back with ./manage.py migrate my_app 0001 --fake
and set up database as it should be manually. Fake means that no schema altering would be done, but notes of migrations run will be removed.
Second, you pushed you code and someone else have run your migrations. In this case you need to create a new migration that reverts anything you've done with 2 and 3. This way anyone will revert unneeded changes by running your new migration.