everything works!

This commit is contained in:
dimitar committed 2024-11-02 09:26:40 +01:00
1 parent 01017bb36e
commit a32992b17b
19 files changed
+1554 -727

No files matched your search

@@ -0,0 +1,44 @@
/*
Warnings:
- You are about to drop the column `content` on the `Document` table. All the data in the column will be lost.
- You are about to drop the column `sharedWithId` on the `Document` table. All the data in the column will be lost.
- Added the required column `uploadedById` to the `Document` table without a default value. This is not possible if the table is not empty.
- Added the required column `documentId` to the `Notification` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "Document" DROP CONSTRAINT "Document_sharedWithId_fkey";
-- AlterTable
ALTER TABLE "Document" DROP COLUMN "content",
DROP COLUMN "sharedWithId",
ADD COLUMN "uploadedById" INTEGER NOT NULL,
ALTER COLUMN "status" DROP DEFAULT;
-- AlterTable
ALTER TABLE "Notification" ADD COLUMN "documentId" INTEGER NOT NULL;
-- CreateTable
CREATE TABLE "_SharedDocuments" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "_SharedDocuments_AB_unique" ON "_SharedDocuments"("A", "B");
-- CreateIndex
CREATE INDEX "_SharedDocuments_B_index" ON "_SharedDocuments"("B");
-- AddForeignKey
ALTER TABLE "Document" ADD CONSTRAINT "Document_uploadedById_fkey" FOREIGN KEY ("uploadedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Notification" ADD CONSTRAINT "Notification_documentId_fkey" FOREIGN KEY ("documentId") REFERENCES "Document"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_SharedDocuments" ADD CONSTRAINT "_SharedDocuments_A_fkey" FOREIGN KEY ("A") REFERENCES "Document"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_SharedDocuments" ADD CONSTRAINT "_SharedDocuments_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+24 -20
View File
@@ -8,32 +8,36 @@ datasource db {
}
model Document {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
title String
content String?
s3Key String
status String @default("pending")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sharedWithId Int
sharedWith User @relation("SharedDocuments", fields: [sharedWithId], references: [id])
status String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
uploadedById Int
uploadedBy User @relation("UploadedDocuments", fields: [uploadedById], references: [id])
Notification Notification[]
sharedWith User[] @relation("SharedDocuments")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
password String
isAdmin Boolean @default(false)
sharedDocuments Document[] @relation("SharedDocuments")
notifications Notification[]
id Int @id @default(autoincrement())
email String @unique
name String?
password String
isAdmin Boolean @default(false)
uploadedDocuments Document[] @relation("UploadedDocuments")
Notification Notification[]
sharedDocuments Document[] @relation("SharedDocuments")
}
model Notification {
id Int @id @default(autoincrement())
message String
read Boolean @default(false)
userId Int
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
id Int @id @default(autoincrement())
message String
read Boolean @default(false)
userId Int
createdAt DateTime @default(now())
documentId Int
document Document @relation(fields: [documentId], references: [id])
user User @relation(fields: [userId], references: [id])
}