Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you freeze an unfrozen model so you can continue to use South?

Using a fork of someone else's code, I added a model field and did the usual auto migration:

~ $ django_admin.py migrate mezzanine_slides --auto
You cannot use automatic detection, since the previous migration does not have this whole app frozen.
Either make migrations using '--freeze mezzanine_slides' or set 'SOUTH_AUTO_FREEZE_APP = True' in your settings.py.

I tried the obvious options using the hint to no avail, and got nowhere from the documentation.

like image 917
Paul Whipp Avatar asked Mar 26 '14 05:03

Paul Whipp


1 Answers

OK, with some trial and error: I created a 'frozen migration' thus:

~ $ django_admin.py schemamigration --freeze mezzanine_slides mezzanine_slides freeze --empty
Created 0002_freeze.py. You must now edit this migration and add the code for each direction.

Then I edited the resulting migration and deleted my added field so that:

! $ django_admin.py schemamigration  mezzanine_slides --auto
+ Added field caption on mezzanine_slides.Slide
Created 0003_auto__add_field_slide_caption.py. You can now apply this migration with: ./manage.py migrate mezzanine_slides

with that done, the migration worked fine.

like image 161
Paul Whipp Avatar answered Oct 19 '22 00:10

Paul Whipp