使用 Git 时如何处理 Doctrine 迁移?

发布于 2024-11-02 17:10:17 字数 351 浏览 0 评论 0原文

我有一个由 git 控制源代码的 Zend Framework / Doctrine 1.2 项目。在 git 中从一个分支切换到另一个分支时,如何跟踪迁移类?

例如,

分支 A 中,我有一个迁移类文件 (038_version.php)

分支 B 中,我有一个迁移类文件 (039_version.php)

Doctrine 将应用迁移 < em>按顺序基于文件名,所以我必须在分支 B 之前推出分支 A 中的功能,以便让 Doctrine 迁移正常工作。

我是否应该将所有迁移保留在自己的分支中并在上线之前更改数字?

I have a Zend Framework / Doctrine 1.2 project that is source controlled by git. How do you keep track of migration classes when switching from branch to branch in git?

For example

In branch A I have a migration class file (038_version.php)

In branch B I have a migration class file (039_version.php)

Doctrine will apply the migrations sequentially based on the file name, so I have to push out the features in branch A before branch B in order to get Doctrine migration to work.

Should I just keep all migrations in its own branch and change the numbers before going live?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

耳钉梦 2024-11-09 17:10:17

由于分支的作用是隔离开发工作,如果您提出任务这取决于几个分支,所述分支妨碍了。
最好将所有这些分支合并到部署分支中,以便可视化 Doctrine 处理的相关文件。

NDM 敬请指出“复杂分支系统中的数据库迁移”以更好地说明OP的问题:

您可以使其适用于简单的分支模式,但对于任何复杂的情况,这将是一场噩梦。

我现在使用的系统采用了不同的方法:我们无法进行增量迁移,而只能从基线重建数据库

NDM 补充道:

在分支系统中不可能正确地进行顺序迁移

Since a branch is there to isolate a development effort, if you ask a task which depends on several branches, said branches are in the way.
It may be better to merge all those branches in a deployment branch, in order to visualize the relevant files for Doctrine to work on.

NDM kindly points out to "Database migrations in a complex branching system" to better illustrate the OP's question:

You could make it work for simple branch patterns, but for anything complicated, it will be a nightmare.

The system I'm working with now takes a different approach: we have no ability to make incremental migrations, but only to rebuild the database from a baseline

NDM adds:

It's just not possible to do sequential migrations correctly in a branched system

相对绾红妆 2024-11-09 17:10:17

如果你遇到这种情况,你将永远不会有同步的分支。此外,如果您有干净的数据库(例如上线),则不需要迁移,只需在实时站点上删除它们,然后运行

migrations:diff

它就会为您创建一个新的数据库迁移,然后您就可以参与游戏了。

If you have that scenario you will never have branches in sync. Additionally if you have clean DB like going live you do not need the migrations, just remove them on the live site, and run

migrations:diff

And it will create you a new migration for the Db and you are in the game.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文