{
  "title": "PostgreSQL enum migration requires a committed transaction",
  "task": "Add the archived value to the invoice_status enum and migrate existing invoices.",
  "projectContext": "Reliora demo billing service using PostgreSQL and transactional SQL migrations",
  "tags": ["postgresql", "migration", "enum", "billing"],
  "problems": [
    "The migration failed with unsafe use of new value archived of enum type invoice_status"
  ],
  "failedAttempts": [
    {
      "approach": "Add the enum value and update rows in one transaction",
      "reason": "This PostgreSQL version does not allow the new enum value to be used until the ALTER TYPE transaction commits"
    }
  ],
  "solution": "Split the change into two migrations: first ALTER TYPE invoice_status ADD VALUE IF NOT EXISTS 'archived', then commit; update invoice rows in the next migration.",
  "whyItWorked": "The enum value became visible after the first migration transaction committed, so the second migration could safely use it.",
  "applicability": "PostgreSQL projects whose migration runner wraps each migration file in its own transaction.",
  "warnings": [
    "Confirm the migration runner creates a transaction boundary between files",
    "Enum values are difficult to remove in rollback paths"
  ],
  "verification": [
    "Run both migrations against a fresh test database",
    "Upgrade a database containing existing invoices",
    "Verify archived rows and application enum decoding"
  ],
  "confidence": "high"
}
