mirror of
https://github.com/gadgethd/ukmesh.git
synced 2026-12-06 11:14:26 +00:00
* fix(db): let a fresh database replay the migration band past the legacy moves A database rebuilt from the shipped base schema could never reach head. The band stopped at 078 because the P1-4 moves re-home relations that no migration in this tree creates: `message_tags_local`, the `path_sim_*` simulation tables, the derived analytics tables and the privacy cluster exist only on databases provisioned before the move. `ALTER TABLE public.x SET SCHEMA` therefore died with `relation "public.x" does not exist`, and 087 failed separately because nothing in the repo ever created the `planner_export` schema its view lives in. Each legacy-dependent move is now guarded with to_regclass() and emits a NOTICE when it skips, so a base-schema database continues while a legacy-provisioned database still executes the identical statement. 087 creates `planner_export` with IF NOT EXISTS, which leaves an operator-provisioned schema, its owner and its grants untouched. Behaviour on a database that has the legacy relations is unchanged: replaying the band over an identical legacy-provisioned fixture with the origin files and with these files produces a byte-for-byte identical `pg_dump --schema-only` (6211 lines), and the six trigger functions plus the export view definition are textually identical. Tests: migrationBootstrap.integration.test.ts already ran a two-migration subset because of this assumption. legacyMoveReplay.integration.test.ts now replays the whole band on a fresh seeded database (head 135_packet_identity_backfill_chunks.sql, 131 ledger rows) and separately proves the guarded moves still move the relations, carrying their index, comment and grants. * ci: gate the fresh-volume replay before the ingest group test:migration-integration was the tail of test:ingest-integration, so a fresh volume that could not reach migration head only showed up after the whole ingest group passed - and today that group is red on the branch for unrelated reasons, which hides the gate entirely. Run it as its own named step ahead of the ingest group instead, and drop the duplicated tail invocation. * fix(db): accept the pre-guard checksums for the four legacy moves Production already recorded 078/080/081/087 with their pre-guard contents. Without this, the next migrate run would report checksum drift on all four and refuse. The guarded files execute the same statements wherever the relations exist - the pre/post databases were diffed with pg_dump --schema-only and matched byte for byte.