Files
buzz/migrations
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d 08669bca21 migrations: add 0002 single-community -> multi-tenant cutover backfill
Adds the one-off cutover migration that takes a pre-1321 single-community
Postgres to the 1321 multi-tenant schema. Rather than hand-describe the target
(which is how the earlier draft introduced single-tenant PKs on multi-tenant
tables and dropped ~13 community_id FKs), 0002 renames the pre-1321 tables and
enum types aside into a legacy schema, runs 1321's own 0001 verbatim into a
clean public schema, copies every row forward stamped with a default
community_id derived from the deployment host, then drops legacy. Runs in one
transaction with an idempotency guard that refuses a non-pristine DB, so the
migrated schema is identical to a fresh 1321 DB by construction.

Verified end-to-end on a throwaway Postgres seeded with pre-1321 data: exit 0,
zero NULL community_id, search_tsv regenerated, structural diff vs fresh-1321
all-empty (constraints/triggers/indexes/columns), relay boots with zero errors,
and the previously boot-fatal allowlist->relay_members backfill succeeds.
Desktop integration suite is 99/99 green against this script's output.

See OUTBOX/1321_CUTOVER_RUNBOOK.md for the operator runbook (snapshot-is-rollback,
required constraint-level diff gate, RELAY_URL + BUZZ_AUTO_MIGRATE=false caveats).

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
2026-06-28 16:48:26 -04:00
..