Squashing ruby on rails database migrations

Why do it?

There are several reasons why you’d want to squash the database migrations in your Ruby on Rails application:

  1. In a long running project you may end up with hundreds of files in your db/migrate folder over time. Carrying these legacy migrations incurs maintenance overhead. For example, when upgrading the Rails version, you may need to modify those old migrations for syntax changes.

  2. If your build process involves recreating the database to run the tests, it would need to run all of these old migrations. Running a lot of migrations would slow down the build time.

    [Read More]