- Add AdminUser model (username, passwordHash, role enum) - Add Code model (code, createdBy, usedByUserId, timestamps) - Install bcryptjs for password hashing - Run migration add_admin_and_code
65 lines
1.4 KiB
Plaintext
65 lines
1.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())
|
|
clerkId String @unique
|
|
email String?
|
|
name String?
|
|
subdomain String @unique
|
|
templateId Int @default(1)
|
|
title String?
|
|
description String?
|
|
bornDate String?
|
|
passedDate String?
|
|
published Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
images Image[]
|
|
}
|
|
|
|
model Image {
|
|
id String @id @default(cuid())
|
|
url String
|
|
key String
|
|
order Int
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
enum Role {
|
|
SUPER_ADMIN
|
|
ADMIN
|
|
}
|
|
|
|
model AdminUser {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
passwordHash String
|
|
role Role @default(ADMIN)
|
|
createdAt DateTime @default(now())
|
|
createdCodes Code[]
|
|
}
|
|
|
|
model Code {
|
|
id String @id @default(cuid())
|
|
code String @unique
|
|
createdById String
|
|
createdBy AdminUser @relation(fields: [createdById], references: [id])
|
|
usedByUserId String?
|
|
usedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([code])
|
|
@@index([usedByUserId])
|
|
} |