Atlas – Terraform but for Database Migrations
In my experience, this sort of thing breaks down when you have a large production database that requires carefully crafted migrations to avoid affecting the existing system and taking too many locks.<p>For example, with Postgres some indexes have to be performed with &quot;CREATE INDEX CONCURRENTLY&quot; or &quot;DROP INDEX CONCURRENTLY&quot;, which cannot be done inside a transaction. (Also, a &quot;CREATE INDEX&quot; like this can fail halfway and leave behind an invalid index that must be manually deleted.) Whether this must be done with &quot;CONCURRENTLY&quot; or not isn&#x27;t something the tool can know.<p>In some cases, a change must done in multiple steps. For example, if you change a column from &quot;NULL&quot; to &quot;NOT NULL&quot;, you have to provide a default value. Updating the database with a default value can in fact be a huge operation that might even have to be done in multiple stages to avoid locking rows for too long. There&#x27;s no way to easily express this in a DSL. M<p>Then there&#x27;s the database support. A tooo like this needs to support a huge range of features. Postgres has extensions (CREATE INDEX ... USING), special index operator classes, functional indexes, partitioning, and so on. I&#x27;ve seen many ORMs or SQL adapters (ActiveRecord&#x2F;ARel, Squirrel, Goqu, Sequelize) try to be smart with how they let you build SQL from high-level code, but they all fail to cover all cases. (Recently I needed to do &quot;ORDER BY CASE ... END&quot; and was using Goqu, which has support for case expressions, but did not support sorting on them.)<p>So while a tool like this might be good when you&#x27;re just starting out, for a &quot;real&quot; app you want to avoid this sort of automation, because the tool is almost certainly not going to be smart enough.<p>I&#x27;m a fan of non-magical tools that let me just write SQL migrations, like dbmate and Goose, because that gives me full control. Having a tool to magically figure out the diff isn&#x27;t super helpful, because I really need to know the diff myself when writing the migration, in order to make it predictable. It&#x27;s simply more convenient to specify the order yourself.