DEV Community


Posted on • Updated on


Easier database schema management with Ridgepole

Sharing ActiveRecord's schema migrations with teams

It is tough when multiple teams are working on the same Rails application and deploy stuff at a fast pace.
People create migrations without knowing the migrations the other teams are creating at the same time.
You can not ignore them because you can't have multiple sets of migrations in Rails. You can only have a set of migrations.
So you have to keep track of migrations the other teams commit to the repository while you commit your migrations.
Because of that, it is not easy to share the migrations with the other teams withouts slowing them down.


Ridgepole is a database schema manager.
You write Ruby DSL to "Schemafile" and apply it to your database with ridgepole --apply on CLI.

With Ridgepole, you don't need to create migration files every time you want to add some changes to tables in your database.

Ridgepole compares tables in Schemafile and actual tables in the database.
Then it applies the difference with ALTER TABLE if there is any.

It also supports "dry run". Basically you can get SQL it's going to execute without actually executing it.
If you want to do a similar thing with ActiveRecord's schema migration, you need to migrate the migration and then roll it back.
(there was a PR for ActiveRecord to support dry run, but it didn't get merged.

Integration with Rails

There are some gems for it.
(This is my gem. I hope you check it out😁 PRs are welcomeπŸ™)

Thank you for reading this to the end!!


Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git