From 174d1c667b0a00d92cea09975346395eccba62a5 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Fri, 22 May 2026 15:12:07 +0000 Subject: [PATCH] fix(GRO-1533): add missing coat_type/pet_size_category columns in migration 0031 Migration 0031 tries to ALTER the coat_type and pet_size_category columns on the pets table to use new enum types, but no prior migration adds these columns. On a fresh DB (after the reset CronJob wiped all tables), this causes the entire migration chain to fail and roll back. Added ADD COLUMN IF NOT EXISTS before the ALTER TYPE so the migration works both on fresh databases and existing ones with the columns. Co-Authored-By: Paperclip --- packages/db/migrations/0031_buffer_rules.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/db/migrations/0031_buffer_rules.sql b/packages/db/migrations/0031_buffer_rules.sql index 5bfd90a..b4ee53b 100644 --- a/packages/db/migrations/0031_buffer_rules.sql +++ b/packages/db/migrations/0031_buffer_rules.sql @@ -6,8 +6,10 @@ CREATE TYPE "pet_size_category" AS ENUM ('small', 'medium', 'large', 'xlarge'); CREATE TYPE "coat_type" AS ENUM ('smooth', 'double', 'wire', 'curly', 'long', 'hairless'); --- ─── Alter pets columns to use new enums ───────────────────────────────────── +-- ─── Add columns to pets if missing, then cast to enums ────────────────────── +ALTER TABLE "pets" ADD COLUMN IF NOT EXISTS "coat_type" text; +ALTER TABLE "pets" ADD COLUMN IF NOT EXISTS "pet_size_category" text; ALTER TABLE "pets" ALTER COLUMN "coat_type" TYPE "coat_type" USING "coat_type"::text::"coat_type"; ALTER TABLE "pets" ALTER COLUMN "pet_size_category" TYPE "pet_size_category" USING "pet_size_category"::text::"pet_size_category";