Best practice for merging database migrations

I’ve been looking into using the built-in database migration system in CakePHP with Sphynx. One area that I can’t seem to find mentioned in either documentation or use cases is dealing with merging migration files from multiple branches in a repository.

Since the migration files are generated using a timestamp, there should be no collisions in the actual merge. However, I am uneasy proceeding, even with testing, without knowing if out-of-order migrations are expected to happen.

We can control migration actions conflicting by enforcing unrelated database changes in branches, but is it ok to allow multiple migrations to merge into a master branch and then back out to feature branches? The timestamps for migrations will surely get out-of-order at some point.

If the last migration applied to a database has a file timestamp later than a new migration merged and applied, is that unsupported?

Seems like a very easy thing to just test?

I was hoping someone could point me to some official support on it.

I can test it, but if it’s undefined or unsupported there isn’t much point. Testing a couple results doesn’t really guarantee any working order for this sort of thing.

Two potential issues.

One, bin/cake migrations migrate can’t deal with one migration when a “later” migration is already migrated. This is the easy to test part; if it works in one situation, I don’t see why it wouldn’t in general. (And my expectation is that it’ll work.)

Two, your migrations somehow contradict each other. Like, they both try to add a column with the same name. Or one tries to add a column after a column the other deleted. This isn’t really a problem with them being out of order, it’s just a matter of a migration being checked in that doesn’t work with the master branch, can just as easily happen without branching as with.