el.xwx.moe/prisma/schema.prisma
2023-05-22 15:50:48 +03:30

76 lines
2.1 KiB
Plaintext

// Copyright (C) 2022-present Daniel31x13 <daniel31x13@gmail.com>
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
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[]
collectionsJoined UsersAndCollections[]
collectionProtection Boolean @default(false)
whitelistedUsers String[] @default([])
createdAt DateTime @default(now())
}
model Collection {
id Int @id @default(autoincrement())
name String
description String @default("")
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
members UsersAndCollections[]
links Link[]
createdAt DateTime @default(now())
@@unique([name, ownerId])
}
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[]
screenshotPath String
pdfPath String
createdAt DateTime @default(now())
}
model Tag {
id Int @id @default(autoincrement())
name String
links Link[]
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
@@unique([name, ownerId])
}