I’ve mentioned Rails migrations in the past. They provide a way to script database schema changes so that you can keep them in version control and roll back versions of a schema if necessary. One thing about them though is that eventually your list of migrations gets huge. (We’re up to over 20 of them in some of our applications, and there’s no reason why we might not have over 100 some day.)
The question becomes, when do you delete all of your migrations and start over with a fresh schema? It seems to me that eventually it comes time to create a fresh database, run all of your migrations on it, and then export that database to a new file and then delete all of your migrations and call that new file migration #1.
My feeling is that this is a function of application versioning. When you reach a big milestone (the kind you wouldn’t want to roll back from incrementally), it’s time to bundle up all your migrations. Unfortunately, that seems like it would conflict with maintaining an existing application. The schema version is stored in the database for live applications, and if you reset the number you lose the ability to run subsequent migrations against an existing database.
Anyone know if there’s a plan for how to handle this sort of thing in the Rails world that I’m missing? The reason I ask is that we have applications that we’re planning on releasing as open source. They also have live instances that are currently running. For the sake of those applications, it seems logical to never roll up the migrations. Distributing an open source application that has to run 50 migrations to get the database set up seems like a bad plan, though. You could distribute your application with a schema import file, but then when you release subsequent versions, you lose the ability to distribute a migration with them that automatically updates the user’s database.
I guess I need to do some research.