enum CampaignState { DRAFT PUBLISHED CANCELLED } model SeasonalCampaign { id String @id @default(uuid()) @db.Uuid organizationId String @map("organization_id") @db.Uuid collectionId String @map("collection_id") @db.Uuid createdById String @map("created_by_id") @db.Uuid slug String @db.VarChar(100) title String @db.VarChar(160) summary String @default("") @db.VarChar(500) startsAt DateTime @map("starts_at") @db.Timestamptz(3) endsAt DateTime @map("ends_at") @db.Timestamptz(3) state CampaignState @default(DRAFT) version Int @default(0) idempotencyKey String @map("idempotency_key") @db.Uuid requestHash String @map("request_hash") @db.Char(64) publishedById String? @map("published_by_id") @db.Uuid publishedAt DateTime? @map("published_at") @db.Timestamptz(3) cancelledById String? @map("cancelled_by_id") @db.Uuid cancelledAt DateTime? @map("cancelled_at") @db.Timestamptz(3) cancellationReason String? @map("cancellation_reason") @db.VarChar(500) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3) updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3) collection CatalogGroup @relation(fields: [collectionId, organizationId], references: [id, organizationId], onDelete: Restrict) createdBy User @relation("CampaignCreator", fields: [createdById, organizationId], references: [id, organizationId], onDelete: Restrict) publishedBy User? @relation("CampaignPublisher", fields: [publishedById, organizationId], references: [id, organizationId], onDelete: Restrict) cancelledBy User? @relation("CampaignCanceller", fields: [cancelledById, organizationId], references: [id, organizationId], onDelete: Restrict) @@unique([organizationId, slug]) @@unique([organizationId, idempotencyKey]) @@index([organizationId, state, startsAt, endsAt, id]) @@index([organizationId, createdAt, id]) @@map("seasonal_campaigns") }