我们何时应该使用合并迁移--meerge/mergeMigrations,以及何时使用SquashMigration我们可以通过管道执行这些命令,而不是团队中的每个开发人员手动执行这些命令吗?
我们何时应该使用合并迁移--meerge/mergeMigrations,以及何时使用SquashMigration我们可以通过管道执行这些命令,而不是团队中的每个开发人员手动执行这些命令吗?
让我们假设迁移文件fixture 有以下migrations.
./foo
./migrations
0001_initial.py
0002_userprofile.py
0003_article.py
0004_auto_add.py
以上是到现在为止的订单吗?因为我们是团队合作.
./foo
./migrations
0001_initial.py
0002_userprofile.py
0003_article.py
0004_auto_add.py
0005_add_name_in_article.py
./foo
./migrations
0001_initial.py
0002_userprofile.py
0003_article.py
0004_auto_add.py
0005_add_name_in_article.py
0005_add_mobile_in_userprofile.py
Here, the last two migrations have the same dependence, and this is breaking the order of the migration, while Developer2 migrating the migration after merging the develop branch django will provide the hit to merge the migration. After running the command, Django will create a new migration, 0006_merge_add_name_in_article_add_mobile_in_userprofile.py, which is merge the 0005_add_name_in_article.py and 0005_add_mobile_in_userprofile.py
The file contains the
dependencies = [
('app_name', '0005_add_name_in_article'),
('app_name', '0005_add_mobile_in_userprofile'),
]
现在,Developer2个本地分支机构有以下migrations.
./foo
./migrations
0001_initial.py
0002_userprofile.py
0003_article.py
0004_auto_add.py
0005_add_name_in_article.py
0005_add_mobile_in_userprofile.py
0006_merge_add_name_in_article_add_mobile_in_userprofile.py
现在Developer2家公司将筹集一个公关并合并,这样另一个发展音符就会与之冲突.
合并迁移的主要目的是减少数据库级别上的冲突,同时以协作方式工作.并且它将生成用于管理迁移顺序的新迁移文件.
愿你心中浮现一个问题:how many unnecessary files will be created for migration?"
不,根据上面合并和挤压迁移的用例,我们不能在管道上做,因为它的开发者有责任保持有序的迁移,根据Django社区,所有的迁移应该在团队中同步,所以我们不能在管道中做.