Add unique constraint on stages name and festival_edition_id#28
Open
Add unique constraint on stages name and festival_edition_id#28
Conversation
Required for CSV import upsert with ON CONFLICT specification. https://claude.ai/code/session_01DpTFYTgNZPgZCCD2YNQsot
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
chiptus
pushed a commit
that referenced
this pull request
May 11, 2026
The migration was failing on staging because (a) the artists.slug dedup suffix wasn't guaranteed unique — using just the first 6 chars of the id can still collide — and (b) stages had duplicate (edition, name) pairs in prod that blocked the new unique constraint outright. Switch both dedups to append the full id, which is guaranteed unique. Add a stages dedup mirroring the artists one. Wrap both ADD CONSTRAINT statements in DO blocks that skip if a constraint of the same name (or the equivalent stages_name_festival_edition_id_key from PR #28) already exists, so the migration is safe to re-run.
chiptus
added a commit
that referenced
this pull request
May 11, 2026
The migration was failing on staging because (a) the artists.slug dedup suffix wasn't guaranteed unique — using just the first 6 chars of the id can still collide — and (b) stages had duplicate (edition, name) pairs in prod that blocked the new unique constraint outright. Switch both dedups to append the full id, which is guaranteed unique. Add a stages dedup mirroring the artists one. Wrap both ADD CONSTRAINT statements in DO blocks that skip if a constraint of the same name (or the equivalent stages_name_festival_edition_id_key from PR #28) already exists, so the migration is safe to re-run.
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
This migration adds a unique constraint to the
stagestable to ensure that stage names are unique within each festival edition.Key Changes
stages_name_festival_edition_id_keyon the combination ofnameandfestival_edition_idcolumns in thestagestableImplementation Details
This constraint prevents duplicate stage names from being created for the same festival edition, while still allowing the same stage name to exist across different festival editions. This maintains data integrity and ensures consistent stage identification within each festival's context.
https://claude.ai/code/session_01DpTFYTgNZPgZCCD2YNQsot