Skip to content

Commit

Permalink
fix(prisma): add location to show unique constraint
Browse files Browse the repository at this point in the history
This patch adds the "location" field to the show unique constraint. This
is required as the same brand _can_ have two different shows (with two
different collections) in the same season but in different locations.

For example, Maticevski had an Australia Spring 2015 RTW collection that
was distinct from (and included different looks than) their Paris Spring
2015 RTW collection (see links included below).

Ref: https://www.vogue.com/fashion-shows/spring-2015-ready-to-wear/maticevski
Ref: https://www.vogue.com/fashion-shows/australia-spring-2015/maticevski
  • Loading branch information
nicholaschiang committed Jul 30, 2023
1 parent fd9f2b3 commit dc6c058
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- A unique constraint covering the columns `[brandId,seasonId,sex,level,location]` on the table `Show` will be added. If there are existing duplicate values, this will fail.
*/
-- DropIndex
DROP INDEX "Show_brandId_seasonId_sex_level_key";

-- CreateIndex
CREATE UNIQUE INDEX "Show_brandId_seasonId_sex_level_location_key" ON "Show"("brandId", "seasonId", "sex", "level", "location");
9 changes: 7 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,14 @@ model Show {
brandId Int
// A brand can only have a single show per season per sex (i.e. "menswear",
// "womenswear", or both) per level (i.e. "couture", "ready-to-wear", etc).
// "womenswear", or both) per level (i.e. "couture", "ready-to-wear", etc) per
// location (e.g. an "Australia" collection alongside a "Paris" collection).
//
// Ex: https://www.vogue.com/fashion-shows/australia-spring-2015/maticevski
// Ex: https://www.vogue.com/fashion-shows/spring-2015-ready-to-wear/maticevski
//
// This constraint was inspired by Vogue's URLs (e.g. /resort-2024/hermes). It
// may need adjustment in the future if there is ever a brand that presents
// twice during a single season (but that probably means I need more seasons).
@@unique([brandId, seasonId, sex, level])
@@unique([brandId, seasonId, sex, level, location])
}

0 comments on commit dc6c058

Please sign in to comment.