开发者

How do you handle Doctrine Migrations when using Git?

开发者_运维问答

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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜