CoastalCommitsPastes/client/prisma/schema.prisma
2022-11-13 23:02:31 -08:00

111 lines
2.6 KiB
Text

generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity", "fullTextSearch"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model SequelizeMeta {
name String @id
}
model File {
id String @id @default(cuid())
title String
content String
sha String
html String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
userId String
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
@@map("files")
}
model Post {
id String @id @default(cuid())
title String
visibility String
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
expiresAt DateTime?
parentId String?
description String?
author User? @relation(fields: [authorId], references: [id])
authorId String
files File[]
@@map("posts")
}
// Next auth stuff, from https://next-auth.js.org/adapters/prisma
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
// https://next-auth.js.org/providers/github
refresh_token_expires_in Int?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map(name: "accounts")
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
// custom fields
posts Post[]
username String? @unique
role String? @default("user")
password String? @db.Text
@@map("users")
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
@@map("verification_tokens")
}