Skip to content

fix(db): remove duplicate add-finding-to-CommentEntityType migration#2872

Merged
tofikwest merged 1 commit into
mainfrom
tofik/fix-duplicate-finding-enum-migration
May 19, 2026
Merged

fix(db): remove duplicate add-finding-to-CommentEntityType migration#2872
tofikwest merged 1 commit into
mainfrom
tofik/fix-duplicate-finding-enum-migration

Conversation

@tofikwest
Copy link
Copy Markdown
Contributor

@tofikwest tofikwest commented May 19, 2026

Summary

Fixes the failing Run Database Migrations check on PR #2869 (main → release).

Two parallel branches independently added 'finding' to the CommentEntityType enum:

  • 20260513220233_comment_entity_type_finding — from feat(cloud-tests): auditor visibility improvements (phases 1-5) (34566555f), merged May 13. Already deployed to staging and on release.
  • 20260512120000_add_finding_to_comment_entity_type — from fix(db): add finding to CommentEntityType (42357e3d3), merged in PR CS-367 [Feature] Ability to add comments directly to findings #2827 on May 19.

Because Prisma orders migrations by filename timestamp, when the main → release deploy ran prisma migrate deploy against staging, it tried to apply the earlier-timestamped May 12 migration after the May 13 one was already applied. The result:

Applying migration `20260512120000_add_finding_to_comment_entity_type`
Error: P3018
Database error code: 42710
ERROR: enum label "finding" already exists

Both migrations were identical (ALTER TYPE "CommentEntityType" ADD VALUE 'finding';). Keeping the one that's already deployed (May 13) and removing the duplicate is the cleanest fix. The Prisma schema is unchanged — the post-migration enum is identical.

Required manual step (staging)

The failed migrate deploy left a row in _prisma_migrations for the May 12 migration with finished_at = NULL. Even after this PR removes the file, migrate deploy will refuse to continue on staging until that record is cleared. Run once against staging (and any other env that hit the error):

bunx prisma migrate resolve --rolled-back 20260512120000_add_finding_to_comment_entity_type

After that, prisma migrate deploy is a no-op for this change — the only remaining migration (May 13) is already applied on staging and release.

Why not make the migration idempotent (ADD VALUE IF NOT EXISTS)?

That would still require the same manual migrate resolve step (to clear the failed-migration record), and would leave a redundant migration in source forever. Removing the duplicate is simpler and leaves the history clean.

Test plan

  • CI Run Database Migrations check passes on this PR
  • After merge + the manual migrate resolve step on staging, the main → release production-deploy PR's database-migrations check passes
  • Fresh local DB (prisma migrate reset) applies cleanly — only the May 13 migration runs to add the finding enum value

🤖 Generated with Claude Code


Summary by cubic

Removes a duplicate Prisma migration that added "finding" to the CommentEntityType enum, unblocking prisma migrate deploy. The schema is unchanged; we keep the already-applied migration.

  • Migration
    • If staging (or any env) has a failed record for this migration, clear it once: bunx prisma migrate resolve --rolled-back 20260512120000_add_finding_to_comment_entity_type
    • After that, prisma migrate deploy is a no-op for this change.

Written for commit 2c6267d. Summary will update on new commits. Review in cubic

Two parallel branches independently added 'finding' to the
CommentEntityType enum:

- 20260513220233_comment_entity_type_finding (from
  feat(cloud-tests): auditor visibility improvements, merged May 13)
- 20260512120000_add_finding_to_comment_entity_type (from
  feat: add comments to findings, merged May 19 in PR #2827)

The May 13 migration was deployed to staging first and recorded the
enum label. When the main->release deploy ran prisma migrate deploy
on staging, it tried to apply the earlier-timestamped May 12
migration and failed with P3018 / 42710 ("enum label \"finding\"
already exists") because the value was already present.

Both migrations did the same thing; keep the one that was actually
deployed (May 13) and remove the duplicate. The schema is unchanged
because the post-migration enum is identical.

A one-time manual step is required on staging (and any environment
where prisma migrate deploy has already recorded the failed
migration) to clear the failed migration record:

    prisma migrate resolve --rolled-back \
      20260512120000_add_finding_to_comment_entity_type

After that, prisma migrate deploy is a no-op for this change because
the only remaining migration (May 13) is already applied.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment May 19, 2026 3:32pm
comp-framework-editor Ready Ready Preview, Comment May 19, 2026 3:32pm
portal Ready Ready Preview, Comment May 19, 2026 3:32pm

Request Review

@tofikwest tofikwest merged commit 12c907b into main May 19, 2026
10 checks passed
@tofikwest tofikwest deleted the tofik/fix-duplicate-finding-enum-migration branch May 19, 2026 15:39
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.58.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants