如何改变南迁顺序
我的 store
应用程序中有大约 50 个迁移,其中一些是 schemamigration
和一些 datamigration
。现在我想在 0037_some_values_to_objects
之前运行 0039_add_column_is_worldwide
。所以我更改了名称 0037_add_column_is_worldwide
和 0039_some_values_to_objects
。
当我为新数据库执行 syncdb
时,它工作正常,但在现有数据库中进行新迁移时,它会出现此错误。
引发异常。不一致的迁移历史记录(问题) Southern.Exceptions.InconcientMigrationHistory:不一致的迁移历史 可以使用以下选项: --merge:将仅尝试迁移,忽略任何潜在的依赖冲突。
我不想丢失数据,那么是否有办法更改这些迁移的顺序?
I have around fifty migrations in my store
app, some of them are schemamigration
and some datamigration
. Now i want to run 0039_add_column_is_worldwide
before 0037_some_values_to_objects
. So I changed there name 0037_add_column_is_worldwide
and 0039_some_values_to_objects
.
It works fine when i did syncdb
for new db but while migrating for a new migration in existing db it gives this error.
raise exceptions.InconsistentMigrationHistory(problems)
south.exceptions.InconsistentMigrationHistory: Inconsistent migration history
The following options are available:
--merge: will just attempt the migration ignoring any potential dependency conflicts.
I didn't want to lose my data, so is there anyway to change the order of these migrations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
运行时迁移存储在数据库中,因此如果您已经应用了这些迁移,南边将会迷路。您的替代方案:
回滚似乎对我来说最安全的是,确保项目中的每个人都这样做。
如果您仍处于开发阶段并且没有产品数据库,您始终可以从零重新启动:
Migration are stored in DB when ran, so if you already applied these migrations south is going to get lost. Your alternatives:
Rollback seems the safest to me, just be sure everybody in your project do the same.
If you are still in dev and you have no prod database, you can always restart from zero:
我猜你的数据库已经完成了“0037_some_values_to_objects”。
我会这样做:
删除“0037_some_values_to_objects”中的forward()和其他方法内的代码。此迁移没有任何作用。现在添加两个新的迁移。
经验法则:如果一个系统已完成迁移,请勿将其删除。让它空起来。
I guess your database has already done "0037_some_values_to_objects".
I would do it like this:
Remove the code inside the forward() and other method in "0037_some_values_to_objects". This migration does nothing. Now add two new migrations.
Rule of thumb: If one system has done a migration, don't delete it. Make it empty.