Replies: 1 comment
|
I don't think this should be solved with a virtual migration. This is fundamentally an expand/contract deployment problem.
I would use two deployments. First, stop referencing the column while it still exists: -- before
SELECT sqlc.embed(users)
FROM users;
-- transition
SELECT id, name, email
FROM users;Regenerate the Go code and deploy that version everywhere. At this point: Only after all old application replicas have been replaced should the second migration run: ALTER TABLE users DROP COLUMN deprecated_column;This gives you:
The core issue is that So I would keep CI enabled and change the query first rather than generating code from an uncommitted/virtual schema. |
Uh oh!
There was an error while loading. Please reload this page.
Hi! We faced a problem that we cannot delete a column.
We use sqlc.embed a lot, and it is essentially is a star expansion over a table's columns, which gets transformed to all columns named individually in the query. The problem is, that if we have a column that we never use in our code, the final query still individually references this column. If we do DROP COLUMN, then a production deploy breaks running code because the column is not available and cause an incident.
The only path I see as a workaround is to:
But it also contradicts our CI, which checks that codegen matched the code (need to disable CI checks) and there's also a chance other developer can merge something between A and B, so we have to schedule merge moratorium to do that.
Is there a way to deprecate a column that I am missing? We are using Encore for migrations, and it does not allow to add a "virtual" migrations that would be skipped.
All reactions