chore: migration

This commit is contained in:
Methapon Metanipat 2024-11-05 09:46:39 +07:00
parent a08bc30a1d
commit 8c02f31d16

View file

@ -0,0 +1,34 @@
/*
Warnings:
- You are about to drop the column `responsibleArea` on the `User` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "User" DROP COLUMN "responsibleArea";
-- CreateTable
CREATE TABLE "UserResponsibleArea" (
"id" TEXT NOT NULL,
"area" TEXT NOT NULL,
CONSTRAINT "UserResponsibleArea_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "_UserToUserResponsibleArea" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "_UserToUserResponsibleArea_AB_unique" ON "_UserToUserResponsibleArea"("A", "B");
-- CreateIndex
CREATE INDEX "_UserToUserResponsibleArea_B_index" ON "_UserToUserResponsibleArea"("B");
-- AddForeignKey
ALTER TABLE "_UserToUserResponsibleArea" ADD CONSTRAINT "_UserToUserResponsibleArea_A_fkey" FOREIGN KEY ("A") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_UserToUserResponsibleArea" ADD CONSTRAINT "_UserToUserResponsibleArea_B_fkey" FOREIGN KEY ("B") REFERENCES "UserResponsibleArea"("id") ON DELETE CASCADE ON UPDATE CASCADE;