diff --git a/prisma/migrations/20230730074359_add_location_to_show_unique_constraint/migration.sql b/prisma/migrations/20230730074359_add_location_to_show_unique_constraint/migration.sql new file mode 100644 index 00000000..7a981262 --- /dev/null +++ b/prisma/migrations/20230730074359_add_location_to_show_unique_constraint/migration.sql @@ -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"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 295d853a..3652aa40 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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]) }