imkFinal/backend/prisma/migrations/20241102061737_destroy/migration.sql
dimitar 3e298a1eef final version
needs file status update[pending, finished]
2025-02-24 23:43:50 +01:00

45 lines
1.8 KiB
SQL

/*
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;