spomeniV2/prisma/schema.prisma
Dimitar765 d6b29b8e9c
Some checks failed
CI / build (push) Has been cancelled
v2 initial commit
2026-08-03 20:33:49 +02:00

76 lines
2.4 KiB
Plaintext

generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid()) @db.VarChar(30)
clerkId String @unique @db.VarChar(100)
email String? @db.VarChar(255)
name String? @db.VarChar(100)
subdomain String @unique @db.VarChar(32)
templateId Int @default(1)
title String? @db.VarChar(100)
description String? @db.VarChar(2000)
// Free-form text — intentionally accepts imprecise values like "1960"
// or "early 1990s", not a parseable date. If structured date queries
// become needed, add a parallel bornDateParsed DateTime? column.
bornDate String? @db.VarChar(50)
passedDate String? @db.VarChar(50)
published Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
images Image[]
}
model Image {
id String @id @default(cuid()) @db.VarChar(30)
url String @db.VarChar(255)
key String @db.VarChar(255)
order Int
userId String @db.VarChar(30)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
@@index([key])
}
enum Role {
SUPER_ADMIN
ADMIN
}
model AdminUser {
id String @id @default(cuid()) @db.VarChar(30)
username String @unique @db.VarChar(50)
passwordHash String @db.VarChar(100)
role Role @default(ADMIN)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdCodes Code[]
}
model Code {
id String @id @default(cuid()) @db.VarChar(30)
code String @unique @db.VarChar(12)
// onDelete: Restrict (Prisma default) — preventing deletion of an
// AdminUser that has issued codes is intentional; we don't want
// orphaned codes with no audit trail of who created them.
createdById String @db.VarChar(30)
createdBy AdminUser @relation(fields: [createdById], references: [id])
usedByUserId String? @db.VarChar(100)
usedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([code])
@@index([usedByUserId])
}