CoastalCommitsPastes/client/prisma/schema.prisma

127 lines
3.1 KiB
Text
Raw Normal View History

2022-11-09 21:38:05 -05:00
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
2022-11-09 21:38:05 -05:00
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
2022-11-09 21:38:05 -05:00
}
model AuthTokens {
id String @default(cuid())
2022-11-09 21:38:05 -05:00
token String
expiredReason String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
2022-11-09 21:38:05 -05:00
deletedAt DateTime?
userId String
// TODO: verify this isn't necessary / is replaced by an implicit m-n relation
// users DriftUser[] @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-11-09 21:38:05 -05:00
@@id([id, token])
// make id and token keys
@@unique([id, token])
}
model SequelizeMeta {
name String @id
}
model File {
id String @id @default(cuid())
title String
content String
sha String @unique
2022-11-09 21:38:05 -05:00
html String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
userId String
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
2022-11-09 21:38:05 -05:00
@@map("files")
2022-11-09 21:38:05 -05:00
}
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")
}
2022-11-09 21:38:05 -05:00
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-11-09 21:38:05 -05:00
}
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")
2022-11-09 21:38:05 -05:00
}