fix(automation): reset test-db schema before restore (avoid P3009 on unreleased migrations) #95
No reviewers
Labels
No labels
bug
claude-failed
claude-pr
claude-queue
claude-working
epic
feature
interactive
portal
triaged
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: shad0w/pelagia-portal#95
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/refresh-test-db-clean-schema"
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?
Fixes the daily
pelagia_testrefresh so unreleased migrations apply cleanly.Problem.
refresh-test-db.shmirrored prod withpg_dump --clean, which only drops objects that exist in prod. Objects created on the test DB by a previously-applied unreleased migration (e.g. the crewing tables/types, before crewing was on prod) survived as leftovers, then collided with themigrate deployreplay —42710 type already exists/ P3009 — which blocked every later migration and 500-ed the staging app.Fix. Drop+recreate
publicbefore the restore, so the test DB starts from exactly prod's objects and the unreleased migrations apply from a clean base. Restore no longer needs--clean. Adds a guard that refuses to run unless the derived target DB name is the expected test DB (it performs aDROP SCHEMA).Already deployed to the pms1 copy (
~/issue-watcher/refresh-test-db.sh, backup kept) so tonight's cron is safe; this PR tracks it in the repo.🤖 Generated with Claude Code
refresh-test-db.sh mirrored prod with `pg_dump --clean`, which only drops objects that exist in prod. Objects created on pelagia_test by a previously-applied UNRELEASED migration (e.g. crewing tables/types not yet released to prod) survived as leftovers, then collided with the `migrate deploy` replay ("type already exists", P3009) — blocking every later migration and 500-ing the staging app. Drop+recreate `public` before the restore so the test DB starts from exactly prod's objects and unreleased migrations apply cleanly. Adds a guard that refuses to run unless the derived target is the expected test DB. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>