12

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?

Shane Stillwell
  • 3,198
  • 5
  • 31
  • 53

2 Answers2

1

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

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This does not answer the question. It's just not possible to do sequential migrations correctly in a branched system... also see http://stackoverflow.com/questions/6409204/database-migrations-in-a-complex-branching-system – NDM Oct 06 '14 at 09:36
  • as OP updated his answer, I would also like to point out that the accepted answer of that post is not the best one, his system just moves the problem elsewhere. the real conclusion is: it's not possible. – NDM Oct 06 '14 at 09:46
0

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.

Enes
  • 1