gpt4 book ai didi

django - 如果我不提交 Django 迁移怎么办?

转载 作者:行者123 更新时间:2023-12-01 01:44:44 25 4
gpt4 key购买 nike

几个月来,我们一直致力于 django 项目。您知道对于开发团队来说,迁移冲突会发生很多次。我搜索了很多,看看其他人对这种问题做了什么,并得到了结果:
What really annoys me about Django migrations
django migrations - workflow with multiple dev branches
Django Migrations and How to Manage Conflicts
How to avoid migration conflicts with other developers?
以及许多其他关于如何避免和解决迁移冲突的文章。
我想知道如果我们只是忽略迁移文件而不提交它们会怎样?
任何答案表示赞赏。

最佳答案

您不应忽略数据库迁移。 Django documentation使这一点非常清楚(重点是我的):

The migration files for each app live in a “migrations” directory inside of that app, and are designed to be committed to, and distributed as part of, its codebase. You should be making them once on your development machine and then running the same migrations on your colleagues’ machines, your staging machines, and eventually your production machines.



您有迁移冲突的事实表明您的多个开发人员都在不同的时间创建他们的迁移,从而导致不同的文件集。如果您按照应有的方式提交迁移,这将永远不会成为问题。

但是,如果您计划压缩迁移(例如,您希望在开发周期中的数据库架构中有大量流失),您可能会等到该周期的所有数据库设计工作完成后再提交迁移。但他们应该始终 promise 。

之后,每个人都将拥有相同的文件集,不再有冲突。

关于django - 如果我不提交 Django 迁移怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51473132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com