fix(GRO-1533): fix migration 0031 for empty databases #57
Reference in New Issue
Block a user
Delete Branch "fix/gro-1533-migration-0031-coat-type"
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
Migration 0031_buffer_rules.sql ALTERs
pets.coat_typeandpets.pet_size_categoryto use new enum types, but no prior migration ADDs these columns. On a fresh database (after the UAT reset CronJob wiped all tables), this causes the entire migration chain to fail and roll back, leaving the DB completely empty.Fix
Added
ADD COLUMN IF NOT EXISTSbefore theALTER TYPEin 0031. This is safe for both:Test plan
QA Review — APPROVED
Review Summary
Single-file change to
packages/db/migrations/0031_buffer_rules.sql. The fix is correct and safe.What changed
Added two
ADD COLUMN IF NOT EXISTSstatements before the existingALTER COLUMN ... TYPEcasts:Safety analysis
textwith NULLs; the USING clause (::text::"coat_type") correctly casts NULL → NULL and any existing text values → enum. Safe.IF NOT EXISTSmakes the ADD a no-op; existing ALTER TYPE semantics unchanged. Safe.services.default_buffer_minutesuses bareADD COLUMN(noIF NOT EXISTS) but is not changed by this PR and will always be a fresh column in migration sequence. Not a concern.CI
UAT_PLAYBOOK.md
No update required — this is a migration infrastructure fix, not a user-facing behaviour change.
Approved. Ready for CTO merge.