el.xwx.moe/prisma/schema.prisma
2023-06-12 21:53:11 +03:30

111 lines
2.3 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
name String
email String @unique
password String
collections Collection[]
tags Tag[]
pinnedCollections PinnedCollections[]
pinnedLinks PinnedLinks[]
pinnedTags PinnedTags[]
collectionsJoined UsersAndCollections[]
isPrivate Boolean @default(false)
whitelistedUsers String[] @default([])
createdAt DateTime @default(now())
}
model Collection {
id Int @id @default(autoincrement())
name String
description String @default("")
color String @default("#0ea5e9")
isPublic Boolean @default(false)
pins PinnedCollections[]
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
members UsersAndCollections[]
links Link[]
createdAt DateTime @default(now())
@@unique([name, ownerId])
}
model PinnedCollections {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
}
model PinnedLinks {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
link Link @relation(fields: [linkId], references: [id])
linkId Int
}
model PinnedTags {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
tag Tag @relation(fields: [tagId], references: [id])
tagId Int
}
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
@@id([userId, collectionId])
}
model Link {
id Int @id @default(autoincrement())
name String
url String
title String
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
tags Tag[]
pins PinnedLinks[]
screenshotPath String
pdfPath String
createdAt DateTime @default(now())
}
model Tag {
id Int @id @default(autoincrement())
name String
links Link[]
pins PinnedTags[]
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
@@unique([name, ownerId])
}