Take the 2-minute tour ×

Is there a way to organize migration files in the db/migrate folder?

Because you quickly have tons of migration files in this folder and it would be great to have something like:

  • db/migrate/user_migrations/
    • timestamp_create_users.rb
    • timestamp_create_addresses.rb

And so on...

Is there a simple way to do this? Some kind of configuration? Is it a bad practice and should I absolutely not do this?

If anyone has any piece of information about that, I'll be glad to hear!

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

There is currently no way to do this and also no reason. There will be cased where a single migration touches several models and features, a model-based categorization is not very appropriate.

You can also delete very old migrations if you already applied them to all your systems or if they invalidate each other (such as the migration to create table A that is then subsequently removed).

Someone may argue that removing a migration may cause the system to not be bootstrapped from scratch. However, migrations should not be used for this. In fact, migrations are only used to alter the database. To load the schema for an empty database you should use $ rake db:schema:load.

share|improve this answer
Ok I better understand why it's not appropriate for a 'model-based' categorization. But wouldn't it be interesting to have a 'app-version-based' categorization of migrations? –  Kulgar Feb 14 '13 at 17:58
Most app doesn't have any version –  Simone Carletti Feb 14 '13 at 19:59
add comment

Your Answer


