Skip to content

Make dd.sql idempotent again and remove one-off migrations - #48

Merged
markmnl merged 1 commit into
mainfrom
idempotent-dd
Sep 22, 2026
Merged

markmnl merged 1 commit into
mainfrom
idempotent-dd

Conversation

@markmnl

@markmnl markmnl commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • dd.sql can 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, and drop trigger if exists before each create trigger (constraint triggers can't be replaced in place). All columns are in the main table definitions — no migration statements.
  • Removes the standalone cmd/fmsg-backfill tool and schema.go (which only embedded dd.sql for it). fmsg.io and fmsg.live were both converted with it on 2026-09-10.
  • Removes temp.sql, the old one-off add-to batch migration from Add to batches #27.

Testing

  • Applied dd.sql twice to an empty Postgres 18 database with ON_ERROR_STOP=1: no errors.
  • go build ./..., go vet ./... and go test ./... pass, with the store integration tests running against Postgres (FMSG_TEST_DATABASE_URL).

Follow-up

  • Run scripts/update-dd.sh in fmsg-docker after merge to refresh 002-fmsgd-dd.sql.

🤖 Generated with Claude Code

#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]>
@markmnl
markmnl merged commit 23d40cc into main Sep 22, 2026
2 checks passed
@markmnl
markmnl deleted the idempotent-dd branch September 22, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant