This commit is contained in:
Daniel
2023-06-12 21:53:11 +03:30
parent 099784699a
commit 69a5d2abd2
11 changed files with 675 additions and 386 deletions
@@ -24,6 +24,33 @@ CREATE TABLE "Collection" (
CONSTRAINT "Collection_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PinnedCollections" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"collectionId" INTEGER NOT NULL,
CONSTRAINT "PinnedCollections_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PinnedLinks" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"linkId" INTEGER NOT NULL,
CONSTRAINT "PinnedLinks_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PinnedTags" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"tagId" INTEGER NOT NULL,
CONSTRAINT "PinnedTags_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "UsersAndCollections" (
"userId" INTEGER NOT NULL,
@@ -82,6 +109,24 @@ CREATE INDEX "_LinkToTag_B_index" ON "_LinkToTag"("B");
-- AddForeignKey
ALTER TABLE "Collection" ADD CONSTRAINT "Collection_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PinnedCollections" ADD CONSTRAINT "PinnedCollections_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PinnedCollections" ADD CONSTRAINT "PinnedCollections_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "Collection"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PinnedLinks" ADD CONSTRAINT "PinnedLinks_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PinnedLinks" ADD CONSTRAINT "PinnedLinks_linkId_fkey" FOREIGN KEY ("linkId") REFERENCES "Link"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PinnedTags" ADD CONSTRAINT "PinnedTags_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PinnedTags" ADD CONSTRAINT "PinnedTags_tagId_fkey" FOREIGN KEY ("tagId") REFERENCES "Tag"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "UsersAndCollections" ADD CONSTRAINT "UsersAndCollections_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+37
View File
@@ -14,6 +14,9 @@ model User {
password String
collections Collection[]
tags Tag[]
pinnedCollections PinnedCollections[]
pinnedLinks PinnedLinks[]
pinnedTags PinnedTags[]
collectionsJoined UsersAndCollections[]
isPrivate Boolean @default(false)
whitelistedUsers String[] @default([])
@@ -26,6 +29,7 @@ model Collection {
description String @default("")
color String @default("#0ea5e9")
isPublic Boolean @default(false)
pins PinnedCollections[]
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
members UsersAndCollections[]
@@ -35,6 +39,37 @@ model Collection {
@@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
@@ -57,6 +92,7 @@ model Link {
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
tags Tag[]
pins PinnedLinks[]
screenshotPath String
pdfPath String
createdAt DateTime @default(now())
@@ -66,6 +102,7 @@ model Tag {
id Int @id @default(autoincrement())
name String
links Link[]
pins PinnedTags[]
owner User @relation(fields: [ownerId], references: [id])
ownerId Int