How can I “cancel” an application from the south (Django)?

In my models.py I have changed a lot, including deleting a large number of fields and renaming several classes. schemamigration --auto worked fine, but the migrate attempt threw a bunch of errors.

All my code is currently under development, so I don't mind losing too much data. Therefore, I want the South to “cancel” or “remove” the application in order to restore all tables again using syncdb .

Or I can delete the entire redirect list and again do schemamigration --initial .

+7
source share
1 answer

Yes, just remove the migration and run schemamigration --initial again. You should do this anyway, like a normal course, before moving on to production. If you have already been in production at least once, do not delete all migrations - only those that you created in the current development cycle, and then run schemamigration --auto to get only one migration instead of potential several.

FWIW, to "disable" the application using the south, you simply delete the "migrations" directory, but in this case there is no need.

UPDATE

It was pointed out that if you have already migrated your application and you delete all migrations and generate one new one, South will complain about the migration still in the database. The actual process that you must follow is:

  • Rollback to the moment before the new migration created in the current development cycle. For example, if you already reached 0005 and you created three new migrations to work on the development you were doing (now in 0008), you will roll back to 0005. If all the migrations are new, you will roll back to zero :

     python manage.py migrate yourapp zero 
  • Delete all migrations that you intend to merge. In the above example, it will be 0006, 0007 and 0008 or for a new application, all in the migration directory, but __init__.py .

  • Create a new migration to close the ones you just deleted. If this is a new application, use --initial , or if it was an existing application, use --auto .

     python manage.py schemamigration --initial yourapp 
  • Move

     python manage.py migrate yourapp 
+11
source

All Articles