feat(infra): adopt node-pg-migrate + backfill initial schema migration #32
No reviewers
Labels
No labels
agent-context-drift
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rstillwell/deckhearth#32
Loading…
Reference in a new issue
No description provided.
Delete branch "convoy/migration-tool"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes P1 #11 of
.convoys/ship-readiness.md(launch sequence step 7) — "No migration tool —scripts/add-*.jsgraveyard". Schema changes post-this-convoy ship asnode-pg-migratemigrations undermigrations/at the repo root; the legacy 27scripts/add-*.js/scripts/fix-*.js/scripts/seed-*.jsjobs remain append-only history per the no-go-zones rule.AGENTS.mdGotcha #6 flips from open → RESOLVED.Decisions (full record in
.convoys/migration-tool.md§ Decisions)node-pg-migrate@^8. JavaScript-native, raw-SQL-friendly viapgm.sql(), ESM-clean. Rejecteddrizzle-kit/prisma migrate/kyselybecause each forces broader TypeScript surface thanAGENTS.mdGotcha #9 allows. Bringspg@^8.21.0as a peer dep (dev-only).migrations/at the repo root. Separates tool-wrapped artifacts from the legacyscripts/migrations/placeholder (which housed2026-05-24-rename-admin-email.jsand remains preserved). Matchesnode-pg-migrate's default--migrations-dir migrations.pgmigrations(no name collision with the existing schema).scripts/setup-neon-db.js's DDL verbatim. Eachawait sql\...`block becomes onepgm.sql(`...`)call. UsesCREATE TABLE IF NOT EXISTS, so the initial migration is idempotent against fresh AND pre-existing envs. Documented assumption: prod has drifted via 27 historicaladd-*.jsscripts; reconciling those is the queuedreconcile-historical-add-scripts` follow-up.setup-neon-db.jsnow (1) validates env vars, (2) spawnsnpm run migrate up, (3) seeds the admin row withON CONFLICT (email) DO NOTHING. DDL ownership moves to the migration.wire-migrate-into-cifollow-up convoy. Real work (needs a test DB + secret OR a Postgres service container); convoy spec authorizes deferral. Risk acknowledged in convoy file § R3.down().The change (per file)
migrations/1779853647564_initial-schema.jsdown()hard-stub (D7).package.jsonmigratescript +node-pg-migrate@^8.0.4+pg@^8.21.0to devDependencies.scripts/setup-neon-db.jsPOSTGRES_URLpre-flight check. AddsrunMigrations()spawn helper.README.mdAGENTS.md.cursor/rules/no-go-zones.mdcnode-pg-migrateflow..cursor/rules/db-and-schema.mdcdocs/SCHEMA_MAP.md.convoys/migration-tool.mdpackage-lock.jsonVerification (all gates green pre-PR)
npm run lint→ exit 1 with 128 problems (baseline preserved, zero regression). New migration file is lint-clean; no new ignore patterns added toeslint.config.mjs.npm run test:run→ 21/21 pass in ~1.3s.node --check migrations/1779853647564_initial-schema.js→ exit 0.node --check scripts/setup-neon-db.js→ exit 0.down()throw verification:npm run migrate -- --help→ returns standardnode-pg-migratehelp text.Live test against a Neon branch: deferred (no throwaway branch available). Optional post-merge operator sequence documented in
.convoys/migration-tool.md§ Operator runbook.Operator runbook (new flow)
Schema change:
Onboarding a new env:
Re-running setup against existing env: idempotent on both halves (
CREATE TABLE IF NOT EXISTS+ON CONFLICT (email) DO NOTHING).Follow-ups surfaced
wire-migrate-into-ci(P2 CI infra) — D6 deferral.reconcile-historical-add-scripts(P1 quality) — fold the 27 historicaladd-*.jseffects into migration history so fresh-env onboarding works without manual script replay. R1 in convoy file.retire-graveyard-scripts-after-audit(P3 polish; blocked on reconcile) — once history captures all effects, delete the legacyscripts/add-*.js/scripts/fix-*.js/scripts/seed-*.jsfiles.audit-node-pg-migrate-transitive-deps(P3 hygiene) — 11npm auditfindings from node-pg-migrate's glob + yargs transitive deps (all dev-only paths; not exercised). R5 in convoy file.add-migration-template(P3 DX) — custom template via--template-file-nameif migration authoring proves inconsistent.Made with Cursor
The latest updates on your projects. Learn more about Vercel for GitHub.
Pipeline Health
Build + CI gates
Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).
Role reports
See individual comments above for details. This rollup updates automatically.