el.xwx.moe/prisma/schema.prisma

149 lines
3.9 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 User {
2023-10-27 15:06:42 -05:00
id Int @id @default(autoincrement())
name String
2023-10-27 15:06:42 -05:00
username String? @unique
2023-10-27 15:06:42 -05:00
email String? @unique
emailVerified DateTime?
image String?
2023-10-27 15:06:42 -05:00
password String
2023-07-08 05:35:43 -05:00
collections Collection[]
2023-10-27 15:06:42 -05:00
tags Tag[]
pinnedLinks Link[]
collectionsJoined UsersAndCollections[]
whitelistedUsers WhitelistedUser[]
subscriptions Subscription?
2023-06-13 14:19:37 -05:00
archiveAsScreenshot Boolean @default(true)
archiveAsPDF Boolean @default(true)
archiveAsWaybackMachine Boolean @default(false)
2023-10-27 15:06:42 -05:00
isPrivate Boolean @default(false)
2023-11-11 13:00:38 -06:00
displayLinkIcons Boolean @default(true)
blurredFavicons Boolean @default(true)
2023-10-27 15:06:42 -05:00
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
}
2023-07-08 05:35:43 -05:00
model WhitelistedUser {
2023-10-27 15:06:42 -05:00
id Int @id @default(autoincrement())
username String @default("")
User User? @relation(fields: [userId], references: [id])
userId Int?
2023-07-08 05:35:43 -05:00
2023-10-27 15:06:42 -05:00
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
2023-07-08 05:35:43 -05:00
}
model VerificationToken {
2023-10-27 15:06:42 -05:00
identifier String
token String @unique
expires DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
2023-07-08 05:35:43 -05:00
@@unique([identifier, token])
2023-01-31 05:36:56 -06:00
}
model Collection {
id Int @id @default(autoincrement())
name String
description String @default("")
color String @default("#0ea5e9")
isPublic Boolean @default(false)
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
members UsersAndCollections[]
links Link[]
2023-10-27 15:06:42 -05:00
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
2023-03-28 02:31:50 -05:00
@@unique([name, ownerId])
2023-01-31 05:36:56 -06:00
}
model UsersAndCollections {
user User @relation(fields: [userId], references: [id])
userId Int
2023-01-31 05:36:56 -06:00
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
2023-01-31 05:36:56 -06:00
canCreate Boolean
canUpdate Boolean
canDelete Boolean
2023-01-31 05:36:56 -06:00
2023-10-27 15:06:42 -05:00
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
2023-01-31 05:36:56 -06:00
@@id([userId, collectionId])
}
model Link {
id Int @id @default(autoincrement())
name String
url String
description String @default("")
pinnedBy User[]
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
tags Tag[]
2023-11-01 05:01:26 -05:00
textContent String?
screenshotPath String?
pdfPath String?
readabilityPath String?
2023-10-31 14:44:58 -05:00
lastPreserved DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
}
model Tag {
id Int @id @default(autoincrement())
name String
links Link[]
owner User @relation(fields: [ownerId], references: [id])
2023-03-28 02:31:50 -05:00
ownerId Int
2023-10-27 15:06:42 -05:00
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
2023-03-28 02:31:50 -05:00
@@unique([name, 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 @updatedAt @default(now())
}