2022-11-09 21:38:05 -05:00
|
|
|
generator client {
|
2022-11-11 22:17:44 -05:00
|
|
|
provider = "prisma-client-js"
|
|
|
|
previewFeatures = ["referentialIntegrity"]
|
2022-11-09 21:38:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
datasource db {
|
2022-11-11 22:17:44 -05:00
|
|
|
provider = "postgresql"
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
referentialIntegrity = "prisma"
|
2022-11-09 21:38:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
model AuthTokens {
|
2022-11-11 22:17:44 -05:00
|
|
|
id String @default(cuid())
|
2022-11-09 21:38:05 -05:00
|
|
|
token String
|
|
|
|
expiredReason String?
|
2022-11-11 22:17:44 -05:00
|
|
|
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
|
2022-11-11 22:17:44 -05:00
|
|
|
// 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
|
2022-11-11 22:17:44 -05:00
|
|
|
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
|
2022-11-11 22:17:44 -05:00
|
|
|
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
2022-11-09 21:38:05 -05:00
|
|
|
|
2022-11-11 22:17:44 -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?
|
2022-11-11 22:17:44 -05:00
|
|
|
author User? @relation(fields: [authorId], references: [id])
|
2022-11-12 02:59:33 -05:00
|
|
|
authorId String
|
2022-11-11 22:17:44 -05:00
|
|
|
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
|
|
|
|
2022-11-11 22:17:44 -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 {
|
2022-11-11 22:17:44 -05:00
|
|
|
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
|
|
|
}
|