many breaking changes/fixes

This commit is contained in:
Daniel
2023-03-28 11:01:50 +03:30
parent 3a5ae28f86
commit b9567ca3c2
43 changed files with 1180 additions and 466 deletions
@@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "Link" RENAME COLUMN "isFavorites" TO "starred";
@@ -37,7 +37,6 @@ CREATE TABLE "Link" (
"url" TEXT NOT NULL,
"title" TEXT NOT NULL,
"collectionId" INTEGER NOT NULL,
"isFavorites" BOOLEAN NOT NULL,
"screenshotPath" TEXT NOT NULL,
"pdfPath" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -50,6 +49,7 @@ CREATE TABLE "Tag" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"collectionId" INTEGER NOT NULL,
"ownerId" INTEGER NOT NULL,
CONSTRAINT "Tag_pkey" PRIMARY KEY ("id")
);
@@ -63,6 +63,12 @@ CREATE TABLE "_LinkToTag" (
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "Collection_name_ownerId_key" ON "Collection"("name", "ownerId");
-- CreateIndex
CREATE UNIQUE INDEX "Tag_name_ownerId_key" ON "Tag"("name", "ownerId");
-- CreateIndex
CREATE UNIQUE INDEX "Tag_name_collectionId_key" ON "Tag"("name", "collectionId");
@@ -87,6 +93,9 @@ ALTER TABLE "Link" ADD CONSTRAINT "Link_collectionId_fkey" FOREIGN KEY ("collect
-- AddForeignKey
ALTER TABLE "Tag" ADD CONSTRAINT "Tag_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "Collection"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Tag" ADD CONSTRAINT "Tag_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_LinkToTag" ADD CONSTRAINT "_LinkToTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Link"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,2 @@
-- DropIndex
DROP INDEX "Tag_name_collectionId_key";
@@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the column `collectionId` on the `Tag` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "Tag" DROP CONSTRAINT "Tag_collectionId_fkey";
-- AlterTable
ALTER TABLE "Tag" DROP COLUMN "collectionId";
+6 -5
View File
@@ -13,6 +13,7 @@ model User {
email String @unique
password String
collections Collection[]
tags Tag[]
collectionsJoined UsersAndCollections[]
createdAt DateTime @default(now())
}
@@ -24,8 +25,9 @@ model Collection {
ownerId Int
members UsersAndCollections[]
links Link[]
tags Tag[]
createdAt DateTime @default(now())
@@unique([name, ownerId])
}
model UsersAndCollections {
@@ -50,7 +52,6 @@ model Link {
collection Collection @relation(fields: [collectionId], references: [id])
collectionId Int
tags Tag[]
starred Boolean
screenshotPath String
pdfPath String
createdAt DateTime @default(now())
@@ -60,8 +61,8 @@ model Tag {
id Int @id @default(autoincrement())
name String
links Link[]
collections Collection @relation(fields: [collectionId], references: [id])
collectionId Int
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
@@unique([name, collectionId])
@@unique([name, ownerId])
}