Updating migration timestamps in feature branches
Let's say there's active development in both my main branch (devlop) and my feature branch. Both are adding migrations now and again. Before merging the feature branch into the main branch, I'm going to rebase it onto the main branch.
So it only makes sense for all the feature branch migrations to come after the most recent develop branch migration.
Is there a handy/advised way to do the r开发者_C百科enaming of these files? I can just generate dummy migrations and reuse the timestamps generated for them -- but I wonder if there's a best/common practice out there that I don't know about?
I haven't found a rails feature to do this for you, but it would be nice to have a migration touch
command or something. At any rate, what we do these days is just generate a new migration, copy the timestamp and rename the old one. Generally migrations are stand alone enough that the order doesn't matter, but occasionally we run into order dependencies so we need to update the timestamps.
As mentioned in the comments on your question, there is no need to change the file names.
It was also mentioned that it won't usually happen that migration is written, depending on an other migration, before that other migration exists. (If it does, your not doing things right). So the need should not arise.
In a rare case where a feature developer would want to merge multiple migrations (where there is a trunk migration in between the feature migrations) (s)he should merge these into a new (or the last) migration. In any case, it's the feature developer's responsibility to make sure dependancies are met.
Doing so could also create some annoying side effects for other developers. The same migration would run again on their database as the timestamp in schema_migrations would not be available.
精彩评论