Files
var-monorepo/packages/database/prisma/migrations/20250222144238_event_appointment/migration.sql
2025-02-22 15:58:04 +01:00

58 lines
2.3 KiB
SQL

/*
Warnings:
- You are about to drop the column `selectedForParticipatioon` on the `Participant` table. All the data in the column will be lost.
- You are about to drop the column `status` on the `Participant` table. All the data in the column will be lost.
- Added the required column `eventAppointmentId` to the `Participant` table without a default value. This is not possible if the table is not empty.
*/
-- AlterEnum
-- This migration adds more than one value to an enum.
-- With PostgreSQL versions 11 and earlier, this is not possible
-- in a single migration. This can be worked around by creating
-- multiple migrations, each migration adding only one value to
-- the enum.
ALTER TYPE "PERMISSION" ADD VALUE 'PILOT';
ALTER TYPE "PERMISSION" ADD VALUE 'DISPO';
-- AlterTable
ALTER TABLE "Participant" DROP COLUMN "selectedForParticipatioon",
DROP COLUMN "status",
ADD COLUMN "eventAppointmentId" INTEGER NOT NULL,
ADD COLUMN "finisherMoodleCurseCompleted" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN "starterMoodleCurseCompleted" BOOLEAN NOT NULL DEFAULT false;
-- CreateTable
CREATE TABLE "EventAppointment" (
"id" SERIAL NOT NULL,
"eventId" INTEGER NOT NULL,
"appointmentDate" TIMESTAMP(3) NOT NULL,
CONSTRAINT "EventAppointment_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "_EventAppointmentToUser" (
"A" INTEGER NOT NULL,
"B" TEXT NOT NULL,
CONSTRAINT "_EventAppointmentToUser_AB_pkey" PRIMARY KEY ("A","B")
);
-- CreateIndex
CREATE INDEX "_EventAppointmentToUser_B_index" ON "_EventAppointmentToUser"("B");
-- AddForeignKey
ALTER TABLE "EventAppointment" ADD CONSTRAINT "EventAppointment_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_eventAppointmentId_fkey" FOREIGN KEY ("eventAppointmentId") REFERENCES "EventAppointment"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_EventAppointmentToUser" ADD CONSTRAINT "_EventAppointmentToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "EventAppointment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_EventAppointmentToUser" ADD CONSTRAINT "_EventAppointmentToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;