Database branching: three-way merge for schema changes
planetscale.com
Database branching: three-way merge for schema changes
1–7 of 7 posts
Re: Database branching: three-way merge for schema changes
#2The DECLARE TABLE statement could list the expected fields, then the SQL engine could create as needed, or alter as needed.
Re: Database branching: three-way merge for schema changes
#3Good article. By describing the workarounds, the article highlights the need for a SQL declarative table statement, something akin to `DECLARE TABLE`. The DECLARE TABLE statement could list the expected fields, then the SQL engine could create as needed, or alter as needed.
Personally, I’m happy with declaring my tables in sqlalchemy and having alembic do the grunt work. Allows me to work in the declarative way you describe while also making it easy to handle the data migration component.
Re: Database branching: three-way merge for schema changes
#4Re: Database branching: three-way merge for schema changes
#5Good article. By describing the workarounds, the article highlights the need for a SQL declarative table statement, something akin to `DECLARE TABLE`. The DECLARE TABLE statement could list the expected fields, then the SQL engine could create as needed, or alter as needed.
The challenge is that more complicated refactoring like renaming columns has to be done through a weird xml DSL.
It also treats static/initial data as out-of-scope.
And it's a product of the bad old days of clumsy closed-source designers and the like.
I use it extensively... and in general, wish I didn't. Maybe it's "grass is always greener" but I wish I'd just stuck to a stack of migration scripts. The fact is that 99% of the time you're deploying to an existing SQL server, so expressing your schema as a series of sequential changes is the only workflow that makes sense, sadly.
Re: Database branching: three-way merge for schema changes
#6Good article. By describing the workarounds, the article highlights the need for a SQL declarative table statement, something akin to `DECLARE TABLE`. The DECLARE TABLE statement could list the expected fields, then the SQL engine could create as needed, or alter as needed.
Re: Database branching: three-way merge for schema changes
#7Good article. By describing the workarounds, the article highlights the need for a SQL declarative table statement, something akin to `DECLARE TABLE`. The DECLARE TABLE statement could list the expected fields, then the SQL engine could create as needed, or alter as needed.
Microsoft has a product called SSDT for this. You provide the SQL schema, it compiles a file called a DACPAC, and provides tools for deploying a DACPAC against a database. Where it can figure out the migration (eg. changing column types, adding columns) it does so automatically. Where it can't (dangerous changes, dropping columns) it blocks. The challenge is that more complicated refactoring like renaming columns has…
(Plus, yeah, BACPAC doesn't solve all the other problems with DACPAC that most of the tools are still clumsy mostly closed-source things that work with Microsoft's SQL Server alone.)