Django南部移民冲突在一个团队工作 [英] Django South migration conflict while working in a team

查看:108
本文介绍了Django南部移民冲突在一个团队工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于如何在团队工作时使用Django-South的简短问题。



如果两个人在同一个文件的更改中同时创建迁移文件,会发生什么?



例如,A和B正在使用相同的Django应用程序。他们正在不同的分支工作,而且在迁移过程005.现在,A和B都使用startmigration来修改apple / models.py并创建迁移文件。他们都在迁移006,但完全不同的迁移文件006.我猜,当他们合并他们的分支时,南方可能会有一些错误。



是否有任何解决方法解决这个冲突?或者南方聪明的自己解决它?

解决方案

南方的文档谈到这个问题:


发生团队和迁移的问题发生在多个人
在同一个时间段内进行迁移时,他们都会承诺
,而其他人已被应用。这类似于两个人
在同一时间在VCS中编辑同一个文件,像VCS一样,South
有解决问题的方法。



如果发生这种情况,首先要注意的是South将检测到
问题,并发出如下消息:

 不一致的迁移历史记录
以下选项可用:
--merge:将尝试迁移,忽略任何潜在的依赖关系
冲突。

如果您使用重新运行迁移 - 合并,南方将简单地应用
错误的无序迁移。这通常工作,因为
团队正在分开模型;如果没有,您需要
查看实际的迁移更改并手动解决它们,因为
可能会发生冲突。



第二件要注意的是,当您将别人的
模型更改与自己的迁移结合使用时,您需要创建一个
新的空迁移,这两个迁移具有两个分支的更改的
开发冻结(如果你使用了mercurial,这相当于
a merge commit)。要这样做,只需运行:

  ./ manage.py schemamigration --empty appname merge_models 

(请注意, merge_models 只是一个迁移名称;更改
任何你喜欢的)



这里的重要信息是,南方不能代替团队
协调 - 事实上,大多数功能都是纯粹警告
你没有协调,简单的合并报价是
只有在容易的情况下。确保您的团队知道谁在使用
,因此他们不会同时写入影响
DB的同一部分的迁移。



I have a short question about how to use Django-South while working in a team.

What happens if two people simultaneously create migration file on changes to the same file?

For example, A and B are working on same Django app. They are working in different branch and both at migration 005. Now, both A and B modifies apple/models.py and created migration file using startmigration. They are both at migration 006 but with completely different migration file 006. I guess when they merge their branches, there might be some error with South.

Is there any workaround to resolve this conflict? Or is South smart enough to resolve it by itself?

解决方案

South's documentation talks about this issue:

The issue with teams and migrations occurs when more than one person makes a migration in the same timeslot, and they both get committed without the other having been applied. This is analogous to two people editing the same file in a VCS at the same time, and like a VCS, South has ways of resolving the problem.

If this happens, the first thing to note is that South will detect the problem, and issue a message like this:

Inconsistent migration history
The following options are available:
    --merge: will just attempt the migration ignoring any potential dependency
        conflicts.

If you re-run migrate with --merge, South will simply apply the migrations that were missing out-of-order. This usually works, as teams are working on separate models; if it doesn’t, you’ll need to look at the actual migration changes and resolve them manually, as it’s likely they’ll conflict.

The second thing to note is that, when you pull in someone else’s model changes complete with their own migration, you’ll need to make a new empty migration that has the changes from both branches of development frozen in (if you’ve used mercurial, this is equivalent to a merge commit). To do so, simply run:

./manage.py schemamigration --empty appname merge_models

(Note that merge_models is just a migration name; change it for whatever you like)

The important message here is that South is no substitute for team coordination - in fact, most of the features are there purely to warn you that you haven’t coordinated, and the simple merging on offer is only there for the easy cases. Make sure your team know who is working on what, so they don’t write migrations that affect the same parts of the DB at the same time.

这篇关于Django南部移民冲突在一个团队工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆