巩固Django南迁移 [英] Consolidating Django South Migrations
问题描述
在我的项目的初始阶段,我对模型做了很多更改,因此我结束了很多为我的应用程序生成的南迁移。在进入我的生产服务器执行迁移之前,是否可以以任何方式合并它们,所以我对每个应用程序没有一百万次迁移?
In the initial stages of my project I'm making a lot of changes to the models and thus I've ended up with a lot of south migrations being generated for my apps. Is it possible to consolidate them in any way before going to my production server to perform the migrations so I don't have like a million migrations for each app? And if so, how would I go about doing that?
推荐答案
您可以随时删除现有迁移和创建新的初始迁移。
You could always delete the existing migrations and create a new "initial" migration.
要执行此操作,您需要:
To do this, you will need to:
- 删除应用程序的迁移文件)
- 运行
./ manage.py convert_to_south myapp
- Remove the migration files for you app (remove the folder altogether)
- Run
./manage.py convert_to_south myapp
b $ b
这会让你对应于应用程序的状态当前状态的单个迁移。
This will leave you with a single migration corresponding to your app's state current state.
您可以随时将最新的迁移包装在一起:
Alternatively, you can always pack your latest migrations together:
- 删除要合并的迁移文件(仅当它们是最新的迁移) / li>
- 运行
./ manage.py schemamigration myapp
- Remove the migration files that you want to merge (only if they are the latest onces)
- Run
./manage.py schemamigration myapp
$ b b
这将创建一个与您删除的迁移相对应的新迁移。
This will create a new migration that will correspond to the migrations you removed.
这两个都可能会弄乱你的开发数据库。
Both of these will likely mess up your development DB.
这篇关于巩固Django南迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!