zlacker

[parent] [thread] 6 comments
1. dewey+(OP)[view] [source] 2026-02-05 00:02:49
I'm always in the market for new sql tooling, but I'm wondering what's the use case there?

Isn't it much quicker to write a one line migration vs copying the DDL, then adapting it to the desired state and then getting getting the migrations from that tool? Or am I misunderstanding something?

replies(1): >>evanel+m1
2. evanel+m1[view] [source] 2026-02-05 00:11:47
>>dewey+(OP)
Be sure to look at the actual sqldef command-line tool, not the trivial copy-and-paste demo on their website. Declarative schema management is best used combined with a Git repo.

In the big picture, declarative schema management has lots of advantages around avoiding/solving schema drift, either between environments (staging vs prod) or between shards in a sharded setup (among thousands of shards, one had a master failure at an inopportune time).

It's also much more readable to have the "end state" in your repo at all times, rather than a sequence of ALTERs.

There are a bunch of other advantages; I have an old post about this topic here: https://www.skeema.io/blog/2019/01/18/declarative/

It's also quite essential when maintaining nontrivial stored procedures. Doing that with imperative migrations is a gateway to hell. https://www.skeema.io/blog/2023/10/24/stored-proc-deployment...

replies(2): >>montro+D3 >>netgho+gy
◧◩
3. montro+D3[view] [source] [discussion] 2026-02-05 00:28:34
>>evanel+m1
Yes, we've used skeema for this for many years, and it is just plain lovely. Putting into source control your desired end state is so much more intuitive and understandable than accumulating migrations. In a way it's like the difference between jQuery and React -- you just say how you want it to look like in the end, and the computer does the work to figure out how to make it so.
replies(1): >>evanel+vK
◧◩
4. netgho+gy[view] [source] [discussion] 2026-02-05 05:04:20
>>evanel+m1
Out of curiosity, the post you linked mentions that it won't work for renames. What's the approach for these and other types of procedural migrations, such as data transformations (ie: splitting a column, changing a type, etc.)

With a declarative model, would you run the migration and follow immediately with a one off script?

replies(1): >>evanel+2M
◧◩◪
5. evanel+vK[view] [source] [discussion] 2026-02-05 07:06:58
>>montro+D3
Thank you for the kind words about Skeema!
replies(1): >>xeonax+FY
◧◩◪
6. evanel+2M[view] [source] [discussion] 2026-02-05 07:22:28
>>netgho+gy
For both data migrations and renames, there isn't really a one-size-fits-all solution. That's actually true when doing data changes or renames in imperative (incremental) migrations tools too; they just don't acknowledge it, but at scale these operations aren't really viable. They inherently involve careful coordination alongside application deploys, which cannot be timed to occur at the exact same moment as the migration completion, and you need to prevent risk of user-facing errors or data corruption from intermediate/inconsistent state.

With row data migrations on large tables, there's also risk of long/slow transactions destroying prod DB performance due to MVCC impact (pile-up of old row versions). So at minimum you need to break up a large data change into smaller chunked transactions, and have application logic to account for these migrations being ongoing in the background in a non-atomic fashion.

That all said, to answer from a mechanical standpoint of "how do companies using declarative schema management also handle data migrations or renames":

At large scale, companies tend to implement custom/in-house data migration frameworks. Or for renames, they're often just outright banned, at least for any table with user-facing impact.

At smaller scale, yeah you can just pair a declarative tool for schema changes with an imperative migration tool for non-schema changes. They aren't really mutually exclusive. Some larger schema management systems handle both / multiple paradigms.

For MySQL/MariaDB with Skeema in particular, a few smaller-scale data migration approaches are discussed in a separate post, https://www.skeema.io/blog/2024/07/23/data-migrations-impera...

◧◩◪◨
7. xeonax+FY[view] [source] [discussion] 2026-02-05 09:09:44
>>evanel+vK
Its named as if a khajit had DB tools to sell
[go to top]