Legacy migrations in a long-running Rails app

Hi everyone,

I’ve been working on a Rails project that has been in development for quite a while. It has 593 migrations, some of which date back to 2008. Over the years, the project has evolved significantly, and I’ve started to notice challenges with handling this migration clutter.

I considered using a gem like Squasher, but getting these old migrations to run again doesn’t seem worth the effort.

Have you faced a similar issue with old migrations? How did you go about cleaning them up or managing the clutter?

Migrations are only used for moving production further. Once they have done that, they pretty much served their purpose and I usually remove them from the project later on.

Setting up a project locally is done by using bundle exec rails db:create db:schema:load db:seed or the db:prepare command depending on the version of your rails application. That way, you don’t have to run any of the old migrations locally and rely on the generated schema to set up your DB.

Thanks! I think it’s my fondness for the history of the project that keeps me from deleting them. I will go ahead and just do it.

1 Like

You can always re-create a simple set of migrations from all existing tables by adding the gem Brick, and then run:

rails g brick:migrations