fix(db): remove duplicate add-finding-to-CommentEntityType migration#2872
Merged
Conversation
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>
Contributor
|
🎉 This PR is included in version 3.58.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the failing Run Database Migrations check on PR #2869 (main → release).
Two parallel branches independently added
'finding'to theCommentEntityTypeenum:20260513220233_comment_entity_type_finding— fromfeat(cloud-tests): auditor visibility improvements (phases 1-5)(34566555f), merged May 13. Already deployed to staging and onrelease.20260512120000_add_finding_to_comment_entity_type— fromfix(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 deployagainst staging, it tried to apply the earlier-timestamped May 12 migration after the May 13 one was already applied. The result: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 deployleft a row in_prisma_migrationsfor the May 12 migration withfinished_at = NULL. Even after this PR removes the file,migrate deploywill refuse to continue on staging until that record is cleared. Run once against staging (and any other env that hit the error):After that,
prisma migrate deployis a no-op for this change — the only remaining migration (May 13) is already applied on staging andrelease.Why not make the migration idempotent (
ADD VALUE IF NOT EXISTS)?That would still require the same manual
migrate resolvestep (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
migrate resolvestep on staging, the main → release production-deploy PR's database-migrations check passesprisma migrate reset) applies cleanly — only the May 13 migration runs to add thefindingenum value🤖 Generated with Claude Code
Summary by cubic
Removes a duplicate Prisma migration that added "finding" to the
CommentEntityTypeenum, unblockingprisma migrate deploy. The schema is unchanged; we keep the already-applied migration.prisma migrate deployis a no-op for this change.Written for commit 2c6267d. Summary will update on new commits. Review in cubic