Make dd.sql idempotent again and remove one-off migrations - #48
Merged
Merged
Conversation
#44 turned dd.sql into a bootstrap-only schema, so deploys could no longer re-run it. Restore the idempotent style: create table/index if not exists, create or replace function, and drop trigger if exists before each create trigger. All columns stay in the main table definitions; there are no upgrade statements. Both live hosts have been converted, so remove the standalone fmsg-backfill tool (and schema.go, which only embedded dd.sql for it) and the old add-to batch migration temp.sql. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
markmnl
added a commit
to markmnl/fmsg-docker
that referenced
this pull request
Sep 22, 2026
Picks up markmnl/fmsgd#48: the fmsgd schema is idempotent again, so it is safe to re-apply on every deploy. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dd.sqlcan be re-run on every deploy again (psql -v ON_ERROR_STOP=1 -f dd.sql):create table/index if not exists,create or replace function, anddrop trigger if existsbefore eachcreate trigger(constraint triggers can't be replaced in place). All columns are in the main table definitions — no migration statements.cmd/fmsg-backfilltool andschema.go(which only embeddeddd.sqlfor it). fmsg.io and fmsg.live were both converted with it on 2026-09-10.temp.sql, the old one-off add-to batch migration from Add to batches #27.Testing
dd.sqltwice to an empty Postgres 18 database withON_ERROR_STOP=1: no errors.go build ./...,go vet ./...andgo test ./...pass, with the store integration tests running against Postgres (FMSG_TEST_DATABASE_URL).Follow-up
scripts/update-dd.shin fmsg-docker after merge to refresh002-fmsgd-dd.sql.🤖 Generated with Claude Code