There are about a hundred or so migrations in my migrate folder with numeric prefixes, then about a hundred or so with timestamp prefixes, so i guess at some point Rails version was updated. Now I want to go stop Rails from using timestamp prefixes as i prefer numeric prefixes. What is the best way to accomplish this, or is this even possible? One approach may be to manually rename the prefixes in their sort order, and then go to dev, staging and production databases and change the timestamps by the new numbers, but this approach looks messy. is there some other way to accomplish this?
views:
275answers:
1Timestamped migrations are awesome if you have a team, or if you want to branch and work on something else. However you can change how migrations are named with a config setting.
#environment.rb
config.active_record.timestamped_migrations = false
Also.... the lazy_developer plugin I maintain has a task to transform all of your migration files into a brand-new migration. I make no warranties that it will work for you, but I've used it on a few projects to get things where i want them to be.
http://github.com/napcs/lazy%5Fdeveloper
It basically takes schema.rb and makes a new migration from it. It tries to handle your indexes too, but it does use a timestamp for the migration number, setting the new migration it creates to the same name as the last migration so that your database's versioning is correctly maintained.
Again, no guarantee this will work, so backup or branch your project first!
If I were you, I'd leave this alone. It's convention to have the migration names, and really, you only have to use them at most once. If you're deploying to a new server or checking the project out to a new machine, you should really use rake db:schema:load instead as it's much faster. Migrations are meant for development and incremental db changes. And like I said, timestamped migrations rock for multiple users.