Personally I've always called this style "declarative schema management" since the input declares the desired state, and the tool figures out how to transition the database to that state.

sqldef is really cool for supporting many database dialects. I'm the author of Skeema [1] which includes a lot of functionality that sqldef lacks, but at the cost of being 100% MySQL/MariaDB-specific. Some other DB-specific options in this space include Stripe's pg-schema-diff [2], results [3], stb-tester's migrator for sqlite [4], among many others over the years.

The more comprehensive solutions from ByteBase, Atlas, Liquibase, etc tend to support multiple databases and multiple paradigms.

And then over in Typescript ORM world, the migrators in Prisma and Drizzle support a "db push" declarative concept. (fwiw, I originated that paradigm; Prisma directly copied several aspects of `skeema push`, and then Drizzle copied Prisma. But ironically, if I ever complete my early-stage next-gen tool, it uses a different deployment paradigm.)

[1] https://github.com/skeema/skeema/

[2] https://github.com/stripe/pg-schema-diff

[3] https://github.com/djrobstep/results

[4] https://david.rothlis.net/declarative-schema-migration-for-s...

I like how Drizzle provides several options for the migrations.

1. DB is source of truth, generate TS from DB 2. TS to DB direct sync, no migration files 3. TS source, Drizzle generates and applies SQL 4. TS source, Drizzle generates SQL, runtime application 5. TS source, Drizzle generates SQL, manual application 6. TS source, Drizzle outputs SQL, Atlas application

> Personally I've always called this style "declarative schema management" since the input declares the desired state, and the tool figures out how to transition the database to that state.

Personally I've called it a mistake, since there's no way a tool can infer what happened based on that information.

For schema changes, it absolutely can, for every situation except table renames or column renames.

That might sound like a major caveat, but many companies either ban renames or have a special "out-of-band" process for them anyway, once a table is being used in production. This is necessary because renames have substantial deploy-order complexity, i.e. you cannot make the schema change at the same exact instant as the corresponding application change, and the vast majority of ORMs don't provide anything to make this sane.

In any case, many thousands of companies use declarative schema management. Some of the largest companies on earth use it. It is known to work, and when engineered properly, it definitely improves development velocity.

Uh, any database of sufficient size is going to do migrations “out of band” as they can take hours or days and you never have code requiring those changes ship at migration start.

Small things where you don’t have DBA or whatever, sure use tooling like you would for auto-changes in a local development.

Very large tech companies completely automate the schema change process (at least for all common operations) so that development teams can make schema changes at scale without direct DBA involvement. The more sophisticated companies handle this regardless of table size, sharding, operational events, etc. It makes a massive difference in execution speed for the entire company.

Renames aren't compatible with that automation flow though, which is what I meant by "out-of-band". They rely on careful orchestration alongside code change deploys, which gets especially nasty when you have thousands of application servers and thousands of database shards. In some DBMS, companies automate them using a careful dance of view-swapping, but that seems brittle performance-wise / operationally.

Not to mention apps that may have differing versions deployed on client infrastructure with different test/release cycles... this is where something like grate is really useful imo.

What do you think of the approach that pg_roll takes?

Seems like the top contenders, at least for Postgres, are:

sqldef: https://news.ycombinator.com/item?id=46845239

pgschema: https://github.com/pgschema/pgschema

pg_roll: https://github.com/xataio/pgroll

atlas: https://github.com/ariga/atlas

grate (minimal SQL-based migrations): https://grate-devs.github.io/grate/

pg-schema-diff: https://github.com/stripe/pg-schema-diff

results: https://github.com/djrobstep/results

https://david.rothlis.net/declarative-schema-migration-for-s...

pgroll is definitely interesting; it overlaps between both schema management tools and online schema change tools. At scale, I would want to have a better understanding on the performance implications of putting views in front of hot tables. I don't like its use of YAML. iiuc, it is an imperative migration tool, not a declarative tool.

Grate is also imperative, not declarative.

That last link (david.rothlis.net) is about a declarative tool for sqlite, not Postgres.