Reputation: 27611
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:
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?
Upvotes: 3
Views: 1207
Reputation: 11079
We always create a bootstrap rake task. This task drops the development db, runs all migrations in turn and then fills it with bogus testing data.
Besides having tons of content in your app to use, you also have to run all migrations. If you do this before you commit your stuff, you're sure all migrations will work for others as well.
Upvotes: 0
Reputation: 13306
This seems more like a team communication problem, or a plain process problem. The migration versions where changed from sequential numbers to timestamps to avoid the problem where developers A and B create a migration with the same version.
In order to avoid migration conflicts:
Now your scenario looks like this:
Never push to a shared repo without making sure your changes won't introduce a conflict or break the build.
Upvotes: 6