We have a team of developers who are each going to be developing database migrations for our system using the Rails tools. Migrations seems at first like a great way to manage changes to the database schema, but as we go on it has become harder to manage changes in a distributed way. If we each develop migrations on our own, how can we reconcile the problems that occur?
To be specific about the problems, imagine the following scenario timeline:
- Developer A creates a new migration file timestamped with 9:00 a.m.
- Developer B creates another new migration file timestamped with 10:00 a.m.
- Developer B checks in the migration dated 10:00 a.m. at 11:00 a.m.
- Developer A checks in the migration dated 9:00 a.m. at 11:30 a.m.
There are a number of problems that can occur here, especially if the two migration files conflict in their changes, but the most basic problem is that some people have run the 10:00 a.m. migration when the 9:00 a.m. migration is checked in. The timestamps associated with the migrations are of course when the file was created, not when it was checked in, which will mess up the Rails migrator.
This is a fixable problem, but the solution could be plenty of different options. What is the best way (or at least a good way) to solve this problem?