开发者

How to automate south migrations in an install script

I have a Django project using South that includes an install script. What I'd like to do is have a couple of lines of code in that install script that take care of installing and syncing my database with my latest code so that new installations of the project can easily get their database set up.

I could run...

python manage.py migrate --fake 0010 appname1
python manage.py migrate --fake 0004 appname2

...but I can't put that into the install script because (1)I don't know the migration number in advance, and (2) I'd rather not have to keep the install script up to date with the app names.

What I need is something like:

python manage.py migrate --fake --allmigrations --allapps

Is there a tr开发者_如何学运维ick for this?


Generally speaking you should not be using --fake during your deployment. Fake means it doesn't actually run the migration and if your use case says you are always going to use --fake (because you're doing the migrations by hand) then why are you bothering to try to get them into your deployment script at all.

That said. If you do intend to run the migrations with your deployment script, it's relatively trivial. Simply run manage.py migrate. No app names not migration numbers. You could even do manage.py migrate --fake and it will fake migrate all migrations for all apps. The real question if you do that though is why the heck you would bother.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜