el.xwx.moe/prisma/schema.prisma

184 lines
5.7 KiB
Plaintext
Raw Normal View History

2023-01-31 05:36:56 -06:00
generator client {
provider = "prisma-client-js"
}
datasource db {
2023-08-04 16:41:53 -05:00
provider = "postgresql"
url = env("DATABASE_URL")
2023-01-31 05:36:56 -06:00
}
model Account {
id String @id @default(cuid())
userId Int
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
2023-01-31 05:36:56 -06:00
model User {
id Int @id @default(autoincrement())
2023-10-27 15:06:42 -05:00
name String
username String? @unique
email String? @unique
2023-10-27 15:06:42 -05:00
emailVerified DateTime?
2024-05-16 14:02:22 -05:00
unverifiedNewEmail String?
image String?
password String?
locale String @default("en")
accounts Account[]
collections Collection[]
2023-10-27 15:06:42 -05:00
tags Tag[]
pinnedLinks Link[]
collectionsJoined UsersAndCollections[]
collectionOrder Int[] @default([])
whitelistedUsers WhitelistedUser[]
accessTokens AccessToken[]
subscriptions Subscription?
linksRouteTo LinksRouteTo @default(ORIGINAL)
2024-03-05 08:03:04 -06:00
preventDuplicateLinks Boolean @default(false)
archiveAsScreenshot Boolean @default(true)
archiveAsPDF Boolean @default(true)
archiveAsWaybackMachine Boolean @default(false)
isPrivate Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
2023-07-08 05:35:43 -05:00
enum LinksRouteTo {
ORIGINAL
PDF
READABLE
SCREENSHOT
}
model WhitelistedUser {
id Int @id @default(autoincrement())
username String @default("")
User User? @relation(fields: [userId], references: [id])
userId Int?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2023-07-08 05:35:43 -05:00
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2023-07-08 05:35:43 -05:00
@@unique([identifier, token])
2023-01-31 05:36:56 -06:00
}
2024-05-18 11:16:00 -05:00
model PasswordResetToken {
identifier String
token String @unique
expires DateTime
createdAt DateTime @default(now())
2024-05-18 11:18:43 -05:00
updatedAt DateTime @default(now()) @updatedAt
2024-05-18 11:16:00 -05:00
}
2023-01-31 05:36:56 -06:00
model Collection {
id Int @id @default(autoincrement())
name String
description String @default("")
color String @default("#0ea5e9")
parentId Int?
parent Collection? @relation("SubCollections", fields: [parentId], references: [id])
subCollections Collection[] @relation("SubCollections")
isPublic Boolean @default(false)
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
members UsersAndCollections[]
links Link[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2024-03-10 05:08:28 -05:00
@@index([ownerId])
2023-01-31 05:36:56 -06:00
}
model UsersAndCollections {
user User @relation(fields: [userId], references: [id])
userId Int
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
canCreate Boolean
canUpdate Boolean
canDelete Boolean
2023-11-20 11:48:41 -06:00
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2023-10-27 15:06:42 -05:00
2023-01-31 05:36:56 -06:00
@@id([userId, collectionId])
2024-03-10 05:08:28 -05:00
@@index([userId])
}
model Link {
id Int @id @default(autoincrement())
name String @default("")
type String @default("url")
description String @default("")
pinnedBy User[]
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
tags Tag[]
url String?
textContent String?
preview String?
image String?
pdf String?
readable String?
lastPreserved DateTime?
2024-03-27 02:20:00 -05:00
importDate DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model Tag {
id Int @id @default(autoincrement())
name String
links Link[]
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2023-10-27 15:06:42 -05:00
2023-03-28 02:31:50 -05:00
@@unique([name, ownerId])
2024-03-10 05:08:28 -05:00
@@index([ownerId])
2023-06-02 06:59:52 -05:00
}
model Subscription {
id Int @id @default(autoincrement())
active Boolean
stripeSubscriptionId String @unique
currentPeriodStart DateTime
currentPeriodEnd DateTime
user User @relation(fields: [userId], references: [id])
userId Int @unique
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
2023-11-20 11:48:41 -06:00
model AccessToken {
id Int @id @default(autoincrement())
2024-01-13 00:20:06 -06:00
name String
user User @relation(fields: [userId], references: [id])
userId Int
token String @unique
revoked Boolean @default(false)
2024-06-26 20:38:34 -05:00
isSession Boolean @default(false)
expires DateTime
lastUsedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2023-11-20 11:48:41 -06:00
}