el.xwx.moe/prisma/schema.prisma

76 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-04-23 08:26:39 -05:00
// 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/>.
2023-01-31 05:36:56 -06:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
2023-01-31 05:36:56 -06:00
name String
email String @unique
2023-01-31 05:36:56 -06:00
password String
collections Collection[]
2023-03-28 02:31:50 -05:00
tags Tag[]
collectionsJoined UsersAndCollections[]
isPrivate Boolean @default(false)
2023-05-18 13:02:17 -05:00
whitelistedUsers String[] @default([])
createdAt DateTime @default(now())
2023-01-31 05:36:56 -06:00
}
model Collection {
id Int @id @default(autoincrement())
2023-01-31 05:36:56 -06:00
name String
2023-04-24 16:30:40 -05:00
description String @default("")
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
members UsersAndCollections[]
links Link[]
createdAt DateTime @default(now())
2023-03-28 02:31:50 -05:00
@@unique([name, ownerId])
2023-01-31 05:36:56 -06:00
}
model UsersAndCollections {
2023-01-31 05:36:56 -06:00
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
@@id([userId, collectionId])
}
model Link {
id Int @id @default(autoincrement())
name String
url String
2023-03-06 14:08:11 -06:00
title String
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
tags Tag[]
2023-03-06 14:08:11 -06:00
screenshotPath String
pdfPath String
createdAt DateTime @default(now())
}
model Tag {
id Int @id @default(autoincrement())
name String
links Link[]
2023-03-28 02:31:50 -05:00
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
2023-03-28 02:31:50 -05:00
@@unique([name, ownerId])
2023-01-31 05:36:56 -06:00
}