// GRV Summit — Postgres source of truth. // Rules: timestamps are UTC timestamptz, money is integer minor units, points are derived from Scan rows. // The schema is expected to grow: application step answers stay in Json columns so the form can change freely. generator client { provider = "prisma-client" output = "../src/generated/prisma" moduleFormat = "esm" } datasource db { provider = "postgresql" } // ---------------------------------------------------------------- applications (ported from D1) enum ApplicationStatus { DRAFT SUBMITTED UNDER_REVIEW SHORTLISTED FINALIST ACCEPTED REJECTED } model Application { id String @id @default(uuid()) editionId String @map("edition_id") resumeToken String @unique @default(uuid()) @map("resume_token") status ApplicationStatus @default(DRAFT) founderName String? @map("founder_name") email String // lowercase phone String? // 9 digits after +251 role String? startupName String? @map("startup_name") website String? city String? yearFounded Int? @map("year_founded") coFounders Int? @map("co_founders") teamSize String? @map("team_size") stage String? primarySector String? @map("primary_sector") secondarySector String? @map("secondary_sector") otherSector String? @map("other_sector") referralSource String? @map("referral_source") // ponytail: Drive/Dropbox links; move to private object storage uploads when needed. businessPlanUrl String? @map("business_plan_url") pitchDeckUrl String? @map("pitch_deck_url") licenseUrl String? @map("license_url") licenseStatus String? @map("license_status") licenseNote String? @map("license_note") tin String? demoUrl String? @map("demo_url") product Json? mindset Json? goals Json? consents Json? createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz submittedAt DateTime? @map("submitted_at") @db.Timestamptz reviews Review[] @@unique([editionId, email]) @@index([editionId, status]) @@map("applications") } model Sector { id Int @id @default(autoincrement()) name String @unique sortOrder Int @default(0) @map("sort_order") active Boolean @default(true) @@map("sectors") } /// One review per reviewer (staff email) per application. scores = { criterionId: 1-5 }. model Review { id String @id @default(uuid()) applicationId String @map("application_id") application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade) reviewer String scores Json total Float comment String? createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz @@unique([applicationId, reviewer]) @@map("reviews") } // ---------------------------------------------------------------- accounts enum Role { ATTENDEE STAFF ADMIN } model User { id String @id @default(uuid()) email String @unique // lowercase name String? role Role @default(ATTENDEE) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz scans Scan[] orders Order[] rafflesWon Raffle[] @@map("users") } model OtpCode { id String @id @default(uuid()) email String codeHash String @map("code_hash") attempts Int @default(0) expiresAt DateTime @map("expires_at") @db.Timestamptz usedAt DateTime? @map("used_at") @db.Timestamptz createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz @@index([email, createdAt]) @@map("otp_codes") } // ---------------------------------------------------------------- inquiries (exhibitors, partners, sponsors, press…) enum InquiryStatus { NEW CONTACTED CLOSED } model Inquiry { id String @id @default(uuid()) intent String // see src/shared/inquiry.ts inquiryIntents name String email String company String? phone String? message String payload Json // the full validated form, so new form fields need no migration status InquiryStatus @default(NEW) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz @@index([intent, status]) @@map("inquiries") } // ---------------------------------------------------------------- commerce model TicketTier { id String @id @default(uuid()) code String @unique // matches the site's ticket id, e.g. "summit-pass" name String description String @default("") scheduleLabel String? @map("schedule_label") features Json @default("[]") priceMinor Int @map("price_minor") currency String @default("USD") capacity Int? sortOrder Int @default(0) @map("sort_order") active Boolean @default(true) orderItems OrderItem[] tickets Ticket[] discounts DiscountCode[] @@map("ticket_tiers") } /// Uses are counted from PAID/FULFILLED orders, never stored. model DiscountCode { id String @id @default(uuid()) code String @unique // uppercase percentOff Int? @map("percent_off") amountOffMinor Int? @map("amount_off_minor") tierId String? @map("tier_id") tier TicketTier? @relation(fields: [tierId], references: [id]) maxUses Int? @map("max_uses") startsAt DateTime? @map("starts_at") @db.Timestamptz endsAt DateTime? @map("ends_at") @db.Timestamptz active Boolean @default(true) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz orders Order[] @@map("discount_codes") } enum OrderKind { TICKET MERCH } enum OrderStatus { PENDING PAID CANCELLED FULFILLED } model Order { id String @id @default(uuid()) number Int @unique @default(autoincrement()) kind OrderKind status OrderStatus @default(PENDING) userId String? @map("user_id") user User? @relation(fields: [userId], references: [id]) buyerName String @map("buyer_name") buyerEmail String @map("buyer_email") buyerPhone String? @map("buyer_phone") company String? paymentMethod String @map("payment_method") // card | bank | booth paymentRef String? @map("payment_ref") subtotalMinor Int @map("subtotal_minor") discountMinor Int @default(0) @map("discount_minor") totalMinor Int @map("total_minor") currency String @default("USD") discountCodeId String? @map("discount_code_id") discountCode DiscountCode? @relation(fields: [discountCodeId], references: [id]) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz paidAt DateTime? @map("paid_at") @db.Timestamptz fulfilledAt DateTime? @map("fulfilled_at") @db.Timestamptz items OrderItem[] tickets Ticket[] @@index([kind, status]) @@index([buyerEmail]) @@map("orders") } /// Exactly one of tierId / merchItemId is set. name + unitPriceMinor are snapshots. model OrderItem { id String @id @default(uuid()) orderId String @map("order_id") order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) tierId String? @map("tier_id") tier TicketTier? @relation(fields: [tierId], references: [id]) merchItemId String? @map("merch_item_id") merchItem MerchItem? @relation(fields: [merchItemId], references: [id]) name String qty Int size String? unitPriceMinor Int @map("unit_price_minor") @@map("order_items") } model Ticket { id String @id @default(uuid()) orderId String @map("order_id") order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) tierId String @map("tier_id") tier TicketTier @relation(fields: [tierId], references: [id]) holderEmail String @map("holder_email") // lowercase; links to User by email holderName String? @map("holder_name") qrToken String @unique @map("qr_token") checkedInAt DateTime? @map("checked_in_at") @db.Timestamptz createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz @@index([holderEmail]) @@map("tickets") } model MerchItem { id String @id @default(uuid()) name String description String? priceMinor Int @map("price_minor") currency String @default("USD") sizes Json @default("[]") stock Int @default(0) // decremented when an order is placed, restored on cancel imageUrl String? @map("image_url") sortOrder Int @default(0) @map("sort_order") active Boolean @default(true) orderItems OrderItem[] @@map("merch_items") } // ---------------------------------------------------------------- event game enum CheckpointKind { BOOTH STARTUP_MEMBER MYSTERY_INVESTEE } model Checkpoint { id String @id @default(uuid()) kind CheckpointKind label String organisation String? boothNumber String? @map("booth_number") personName String? @map("person_name") points Int @default(10) // MYSTERY_INVESTEE awards points * 2 qrToken String @unique @map("qr_token") active Boolean @default(true) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz scans Scan[] @@index([kind]) @@map("checkpoints") } /// Points = SUM(pointsAwarded); the unique pair makes a repeat scan a no-op. model Scan { id String @id @default(uuid()) userId String @map("user_id") user User @relation(fields: [userId], references: [id], onDelete: Cascade) checkpointId String @map("checkpoint_id") checkpoint Checkpoint @relation(fields: [checkpointId], references: [id], onDelete: Cascade) pointsAwarded Int @map("points_awarded") createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz @@unique([userId, checkpointId]) @@index([createdAt]) @@map("scans") } model Raffle { id String @id @default(uuid()) name String prize String minPoints Int @default(0) @map("min_points") drawnAt DateTime? @map("drawn_at") @db.Timestamptz winnerUserId String? @map("winner_user_id") winner User? @relation(fields: [winnerUserId], references: [id]) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz @@map("raffles") }