Simone Carletti Simone Carletti - 1 month ago 10
Ruby Question

Is it a good idea to purge old Rails migration files?

I have been running a big Rails application for over 2 years and, day by day, my ActiveRecord migration folder has been growing up to over 150 files.

There are very old models, no longer available in the application, still referenced in the migrations. I was thinking to remove them.

What do you think? Do you usually purge old migrations from your codebase?

Answer

They are relatively small, so I would choose to keep them, just for the record.

You should write your migrations without referencing models, or other parts of application, because they'll come back to you haunting ;)

Check out these guidelines:

http://guides.rubyonrails.org/migrations.html#using-models-in-your-migrations