-- CreateEnum
CREATE TYPE "PARTICIPANT_STATUS" AS ENUM ('WAITING_FOR_ENTRY_TEST', 'ENTRY_TEST_FAILED', 'READY_FOR_EVENT', 'PARTICIPATED', 'WAITING_FOR_EXIT_TEST', 'EXIT_TEST_FAILED', 'WAITING_FOR_PERMISISONS', 'FINISHED', 'WAVED');

-- CreateTable
CREATE TABLE "Participant" (
    "id" SERIAL NOT NULL,
    "user_id" TEXT NOT NULL,
    "status" "PARTICIPANT_STATUS" NOT NULL,
    "selectedForParticipatioon" BOOLEAN NOT NULL DEFAULT false,
    "statusLog" JSONB[],
    "eventId" INTEGER,

    CONSTRAINT "Participant_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Event" (
    "id" SERIAL NOT NULL,
    "name" TEXT NOT NULL,
    "description" TEXT,
    "discordRoleId" TEXT,
    "hasPresenceEvents" BOOLEAN NOT NULL DEFAULT false,
    "maxParticipants" INTEGER NOT NULL,
    "starterMoodleCourseId" INTEGER,
    "finisherMoodleCourseId" INTEGER,
    "finished" BOOLEAN NOT NULL DEFAULT false,
    "finishedBadges" TEXT[],
    "requiredBadges" TEXT[],
    "finishedPermissions" TEXT[],
    "hidden" BOOLEAN NOT NULL DEFAULT true,

    CONSTRAINT "Event_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "File" (
    "id" SERIAL NOT NULL,

    CONSTRAINT "File_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE SET NULL ON UPDATE CASCADE;
