Converting An App — South v0.7 documentation

使用South迁移Django应用
本文介绍如何将现有的Django应用转换为使用South进行数据库迁移的方法。首先需要在settings.py中添加'south'到INSTALLED_APPS,然后运行syncdb加载South表到数据库。接着使用convert_to_south命令自动生成初始迁移。对于其他安装和服务器,需提交初始迁移至版本控制系统,并在每台机器上使用--fake标志来模拟迁移。

Converting An App — South v0.7 documentation

Converting An App

Converting an app to use South is very easy:

  • Edit your settings.py and put ‘south’ into INSTALLED_APPS
    (assuming you’ve installed it to the right place)
  • Run ./manage.py syncdb to load the South table into the database.
    Note that syncdb looks different now - South modifies it.
  • Run ./manage.py convert_to_south myapp - South will automatically make and
    pretend to apply your first migration.

Note that you’ll need to convert before you make any changes; South detects
changes by comparing against the frozen state of the last migration, so it
cannot detect changes from before you converted to using South.

Converting other installations and servers

The convert_to_south command only works entirely on the first machine you run it
on. Once you’ve committed the initial migrations it made into your VCS,
you’ll have to run ./manage.py migrate myapp 0001 --fake on every machine that
has a copy of the codebase (make sure they were up-to-date with models and
schema first).

(For the interested, this is required because the initial migration that
convert_to_south makes will try and create all the existing tables; instead, you
tell South that it’s already applied using –fake, so the next migrations
apply correctly.)

Remember that new installations of the codebase after this don’t need these
steps; you need only do a syncdb then a normal migrate.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值