54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Get a free hosted Postgres database in seconds: `npx create-db`
|
|
|
|
generator client {
|
|
provider = "prisma-client"
|
|
output = "../lib/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
enum Role {
|
|
User
|
|
Moderator
|
|
Admin
|
|
}
|
|
|
|
enum NewsletterStatus {
|
|
Draft
|
|
Schedule
|
|
Sent
|
|
}
|
|
|
|
model Users {
|
|
id String @id @default(cuid()) // prsima generates cuid - generated text id
|
|
email String @unique
|
|
name String?
|
|
passwordHash String? // g-accounts dont have pword
|
|
googleId String? @unique // stable key for g-accounts
|
|
role Role @default(User)
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
newsletters Newsletters[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Newsletters {
|
|
id String @id @default(cuid())
|
|
title String
|
|
imageUrl String
|
|
content String
|
|
authorID String
|
|
author Users @relation(fields: [authorID], references: [id], onDelete: Cascade) // when the associated user is deleted so is the newsletter
|
|
status NewsletterStatus @default(Draft)
|
|
likes Int @default(0)
|
|
comments String[] @default([])
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
} |