views:

326

answers:

1

Hi I want to use south in my django project as migration tool, but I have problem with using south in multiuser scenario:

two guys working in same time and create on diffrent machines two migrations with same number

  • on first PC: 0007_extend_lizard.py

  • on second PC: 0007_swap_name_adopter.py

in this case i can run ./manage migrate --merge or /manage migrate 0006 (rollback) and run again ./manage migrate. BUT when i want add new field in models.py and run ./manage startmigration southdemo --auto, then south get models = {} meta data from last migration and he have missing info from frist one migration. Result of this is creating migration 0008 with creating again (!!!) changes from first 0007.

How looks best solution for solve this problem ?

currently I thinking about two options:

- manualy merge both 0007 migration in one file and then migrate (but some one must execute "rollback"

- manualy move missing models = {} meta to last 0007 migration and then next --auto in 0008 work perfectly.

what is best option, what im missed ?

sorry for my semi-english

A: 

After doing the migrate --merge or rollback-and-migrate, if you know that the most recent migration now has inaccurate frozen models, I would just create a new no-op migration for the purposes of bringing the frozen models up to date. Just run ./manage.py startmigration myapp --auto freeze_noop and then edit the freeze_noop migration file so its backwards() and forwards() methods both contain just pass. Now your frozen models will be up-to-date for the next time you want to autodetect a real migration.

Maybe it seems a little ugly to create a no-op migration, but to me this seems cleaner than either of the manual history-editing options you suggested. You can think of the no-op migration as the equivalent of a "merge commit" in a DVCS.

This issue ought to be mentioned in this section of the South docs; I've filed an issue for it.

Carl Meyer