-- Migration: 0039_extend_pet_profile_columns_idempotent.sql -- GRO-2033: re-register the temperament/medical/preferred-cuts columns from -- 0034 with an idempotent ADD COLUMN IF NOT EXISTS + a monotonic journal -- `when` (1780000000001), above the 0033 high-water mark (1779500000000) -- and above the most recent applied migration 0038 (1780000000000). -- -- 0034_extend_pet_profile_columns.sql was authored on 2026-05-28 with -- `when` = 1751140800000 (2025-06-28) — *below* the 0033 high-water mark -- of 1779500000000 (2026-05-23). drizzle-orm@0.38.4 -- (pg-core/dialect.js#migrate) only applies a migration when -- `migration.folderMillis > lastDbMigration.created_at`, so on prod — -- whose last applied entry was 0033 at created_at=1779500000000 — 0034 -- was silently skipped, leaving `pets.temperament_score` (and friends) -- missing. The migrate Job still exits 0 ("migrations applied -- successfully!") because the journal high watermark *was* advanced by -- 0038, but no schema change ever ran for 0034. Seed/reset then crash on: -- PostgresError: column "temperament_score" does not exist (42703) -- -- Same pattern as GRO-1999 (0037 → 0038): do NOT modify 0034 in-place -- (UAT/dev have already applied it via their lower watermarks). Add a -- new idempotent migration with a monotonic `when` instead so existing -- DBs apply it cleanly and fresh DBs are a no-op-after-no-op. ALTER TABLE "pets" ADD COLUMN IF NOT EXISTS "temperament_score" integer; ALTER TABLE "pets" ADD COLUMN IF NOT EXISTS "temperament_flags" jsonb DEFAULT '[]'; ALTER TABLE "pets" ADD COLUMN IF NOT EXISTS "medical_alerts" jsonb DEFAULT '[]'; ALTER TABLE "pets" ADD COLUMN IF NOT EXISTS "preferred_cuts" jsonb DEFAULT '[]';