fix(db): forward-fix idea_notifications.kind to ClaudeJobKind enum (replay safety) #54

Merged
janpeter merged 1 commit from fix/idea-notifications-kind-enum-replay into main 2026-05-28 23:42:36 +02:00
Owner

Follow-up to the prod migration incident on 2026-05-28.

Background

prisma migrate deploy failed with P3018 (relation "idea_notifications" already exists). Root cause: migration 20260528174647_add_idea_notifications re-creates a table that already existed (the original creating migration was removed from history), and it declares kind **TEXT** while schema.prisma + the live DB use the ClaudeJobKind enum. Prod was unblocked with prisma migrate resolve --applied 20260528174647_add_idea_notifications (the live schema already matched schema.prisma; no SQL ran). migrate status → up to date.

Why this PR (and why not edit the original)

The applied migration's checksum is recorded in _prisma_migrations; editing its .sql would change the checksum and make prisma migrate deploy reject it — re-breaking deploys. Prisma migrations are append-only, so this is a forward-fix.

What

A new migration that converts idea_notifications.kind to the ClaudeJobKind enum only if it is currently TEXT. On current prod (already enum) it is a no-op (no table rewrite, zero risk); on a from-scratch replay (where 20260528174647 created it as TEXT) it converts the column so the final schema matches schema.prisma. The cast is identity on existing values.

Applied automatically by the next update_scrum4me_web deploy.

Follow-up to the prod migration incident on 2026-05-28. ## Background `prisma migrate deploy` failed with P3018 (`relation "idea_notifications" already exists`). Root cause: migration `20260528174647_add_idea_notifications` re-creates a table that already existed (the original creating migration was removed from history), and it declares `kind **TEXT**` while schema.prisma + the live DB use the **ClaudeJobKind** enum. Prod was unblocked with `prisma migrate resolve --applied 20260528174647_add_idea_notifications` (the live schema already matched schema.prisma; no SQL ran). `migrate status` → up to date. ## Why this PR (and why not edit the original) The applied migration's checksum is recorded in `_prisma_migrations`; editing its `.sql` would change the checksum and make `prisma migrate deploy` reject it — re-breaking deploys. Prisma migrations are append-only, so this is a forward-fix. ## What A new migration that converts `idea_notifications.kind` to the `ClaudeJobKind` enum **only if it is currently TEXT**. On current prod (already enum) it is a no-op (no table rewrite, zero risk); on a from-scratch replay (where 20260528174647 created it as TEXT) it converts the column so the final schema matches schema.prisma. The cast is identity on existing values. Applied automatically by the next `update_scrum4me_web` deploy.
fix(db): forward-fix idea_notifications.kind to ClaudeJobKind enum (replay safety)
Some checks failed
CI / Lint, Typecheck, Test & Build (pull_request) Failing after 3m25s
CI / Deploy Manual (workflow_dispatch) (pull_request) Has been skipped
CI / Detect deploy-relevant changes (pull_request) Has been skipped
CI / Deploy Preview (PR) (pull_request) Has been skipped
CI / Deploy Production (main) (pull_request) Has been skipped
9e80954b51
Migration 20260528174647_add_idea_notifications declared `kind TEXT`, but
schema.prisma and the live DB use the ClaudeJobKind enum. That migration was a
redundant re-add (the table had been created with the enum by an earlier,
since-removed migration), and on prod it CREATE-TABLE-conflicted and was marked
applied via `prisma migrate resolve --applied`. Editing it in place is not an
option — its checksum is recorded, so `prisma migrate deploy` would reject the
modified file. This forward-fix corrects the type so a from-scratch replay of
the migration history (e.g. a fresh env) produces the enum column instead of
TEXT (which would drift from schema.prisma).

Conditional ALTER: a no-op where kind is already the enum (current prod → no
table rewrite); only a genuine TEXT column (fresh replay) is converted. The
cast is identity on existing values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janpeter/Scrum4Me!54
No description provided.