// Church Website 1.0.0 (docs/WEBSITE-1.0-PLAN.md). One database per church. // // The content tables are the **working copy** the admin edits (§4). Publishing writes an immutable // snapshot of them to SiteVersion; visitors always see the latest SiteVersion, the preview sees the // working copy. Shared facts (name, logo, colours, service times, contact, the brand style) are the // church profile's, in Accounts (§2), and are never stored here. generator client { provider = "prisma-client" // Its own output, so hoisted clients of other apps never overwrite it (EVENTS-2.2-PLAN §2). output = "../src/generated/prisma" moduleFormat = "esm" importFileExtension = "js" } datasource db { provider = "postgresql" } /// Website roles (§10). Held here, per product: an Events role gives nothing in the Website. enum WebsiteRole { owner admin editor ministry_leader viewer } enum PageKind { home visit about leadership ministries events messages give contact terms safeguarding custom } enum MessageSource { youtube_feed youtube spotify } /// The site's design in the working copy (one row, id 1): template, section variants, homepage /// order and the Website-only style settings (src/site/variants.ts). Fonts and corners are shared. model SiteDesign { id Int @id @default(1) template String variants Json home Json style Json updatedAt DateTime @updatedAt updatedBy String? } /// A page: the fixed ones (§6) and custom pages built from blocks. model Page { id String @id @default(uuid()) kind PageKind slug String @unique title String /// Per-page SEO (ROADMAP-v3 §11); null uses the generated one. seoTitle String? description String? navLabel String? inNav Boolean @default(true) position Int @default(0) imageId String? archivedAt DateTime? updatedAt DateTime @updatedAt updatedBy String? sections Section[] @@index([kind]) } /// A section or block on a page. `data` is validated with the zod schema for its `type`; `variant` /// is one of that type's ids. Content is never tied to a template (§2). model Section { id String @id @default(uuid()) pageId String page Page @relation(fields: [pageId], references: [id], onDelete: Cascade) type String variant String? position Int @default(0) hidden Boolean @default(false) data Json updatedAt DateTime @updatedAt updatedBy String? @@index([pageId, position]) } model Ministry { id String @id @default(uuid()) slug String @unique name String summary String? body String? imageId String? position Int @default(0) archivedAt DateTime? updatedAt DateTime @updatedAt updatedBy String? leaders WebsiteUser[] } model Leader { id String @id @default(uuid()) name String role String? bio String? photoId String? position Int @default(0) archivedAt DateTime? updatedAt DateTime @updatedAt updatedBy String? } model MessageSeries { id String @id @default(uuid()) slug String @unique title String summary String? imageId String? createdAt DateTime @default(now()) messages Message[] } /// A message (sermon), from the YouTube feed or added by hand (§7). Published on its own, not with /// the site's Publish (decision 9). Audio and video are linked, never uploaded. model Message { id String @id @default(uuid()) slug String @unique title String date DateTime source MessageSource mediaUrl String /// The YouTube video id or Spotify episode id: one message per video, whichever way it came in. externalId String? @unique thumbnailUrl String? speaker String? passage String? notes String? seriesId String? series MessageSeries? @relation(fields: [seriesId], references: [id], onDelete: SetNull) hidden Boolean @default(false) publishedAt DateTime? updatedAt DateTime @updatedAt updatedBy String? @@index([date]) } /// A simple event made in the Website (§8). Registrations and payments are only Cross Events'. model SimpleEvent { id String @id @default(uuid()) slug String @unique title String startsAt DateTime endsAt DateTime? allDay Boolean @default(false) timezone String @default("Africa/Johannesburg") location String? description String? imageId String? link String? cancelled Boolean @default(false) publishedAt DateTime? updatedAt DateTime @updatedAt updatedBy String? @@index([startsAt]) } /// A read-only copy of a sibling's event from the feed (crosscode.event/1, ROADMAP-v3 §4). model ImportedEvent { id String @id @default(uuid()) originProduct String originId String startsAt DateTime data Json syncedAt DateTime @default(now()) @@unique([originProduct, originId]) @@index([startsAt]) } /// An upload: counted towards storage (§10) until neither the working copy nor the last 10 /// published versions use it. model MediaAsset { id String @id @default(uuid()) filename String mime String bytes Int width Int? height Int? alt String @default("") /// The resized files (WebP and JPEG per width) and their sizes, counted with `bytes`. sizes Json? uploadedBy String? createdAt DateTime @default(now()) } /// A published version: an immutable snapshot of the working copy (§4). Restore copies one back. model SiteVersion { id String @id @default(uuid()) number Int @unique snapshot Json note String? publishedBy String publishedAt DateTime @default(now()) } /// A shared preview link (§4): the token is stored hashed, expires after 7 days or when revoked. model PreviewLink { id String @id @default(uuid()) tokenHash String @unique createdBy String createdAt DateTime @default(now()) expiresAt DateTime revokedAt DateTime? } /// Someone who can use the admin: keyed by their account's `sub` from Accounts. model WebsiteUser { id String @id email String name String role WebsiteRole /// A Ministry leader edits only their own ministry. ministryId String? ministry Ministry? @relation(fields: [ministryId], references: [id], onDelete: SetNull) lastSignInAt DateTime? createdAt DateTime @default(now()) } model AuditLog { id String @id @default(uuid()) actorId String? actorRole String action String targetType String targetId String? metadata Json? ip String? createdAt DateTime @default(now()) @@index([createdAt]) } model AppSetting { key String @id value String updatedAt DateTime @updatedAt }