Merge branch 'main' of https://github.com/VAR-Virtual-Air-Rescue/var-monorepo
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Made the column `eventId` on table `Participant` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Participant" DROP CONSTRAINT "Participant_eventId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Event" ALTER COLUMN "maxParticipants" SET DEFAULT 0;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Participant" ALTER COLUMN "eventId" SET NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Event" ALTER COLUMN "discordRoleId" SET DEFAULT '',
|
||||
ALTER COLUMN "starterMoodleCourseId" SET DATA TYPE TEXT,
|
||||
ALTER COLUMN "finisherMoodleCourseId" SET DATA TYPE TEXT;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Event" ALTER COLUMN "starterMoodleCourseId" SET DEFAULT '',
|
||||
ALTER COLUMN "finisherMoodleCourseId" SET DEFAULT '';
|
||||
@@ -0,0 +1,9 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "BADGES" AS ENUM ('P1', 'P2', 'P3', 'D1', 'D2', 'D3', 'DAY1');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PERMISSION" AS ENUM ('ADMIN_EVENT', 'ADMIN_USER', 'SUSPENDED');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "badges" "BADGES"[] DEFAULT ARRAY[]::"BADGES"[],
|
||||
ADD COLUMN "permissions" "PERMISSION"[] DEFAULT ARRAY[]::"PERMISSION"[];
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Participant" DROP CONSTRAINT "Participant_eventAppointmentId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Participant" ALTER COLUMN "eventAppointmentId" DROP NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_eventAppointmentId_fkey" FOREIGN KEY ("eventAppointmentId") REFERENCES "EventAppointment"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `_EventAppointmentToUser` table. If the table is not empty, all the data it contains will be lost.
|
||||
- Added the required column `presenterId` to the `EventAppointment` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "_EventAppointmentToUser" DROP CONSTRAINT "_EventAppointmentToUser_A_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "_EventAppointmentToUser" DROP CONSTRAINT "_EventAppointmentToUser_B_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventAppointment" ADD COLUMN "presenterId" TEXT NOT NULL;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "_EventAppointmentToUser";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_EventAppointmentUser" (
|
||||
"A" INTEGER NOT NULL,
|
||||
"B" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "_EventAppointmentUser_AB_pkey" PRIMARY KEY ("A","B")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_EventAppointmentUser_B_index" ON "_EventAppointmentUser"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventAppointment" ADD CONSTRAINT "EventAppointment_presenterId_fkey" FOREIGN KEY ("presenterId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_EventAppointmentUser" ADD CONSTRAINT "_EventAppointmentUser_A_fkey" FOREIGN KEY ("A") REFERENCES "EventAppointment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_EventAppointmentUser" ADD CONSTRAINT "_EventAppointmentUser_B_fkey" FOREIGN KEY ("B") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -10,27 +10,41 @@ enum PARTICIPANT_STATUS {
|
||||
WAVED
|
||||
}
|
||||
|
||||
model Participant {
|
||||
id Int @id @default(autoincrement())
|
||||
userId String @map(name: "user_id")
|
||||
status PARTICIPANT_STATUS
|
||||
selectedForParticipatioon Boolean @default(false)
|
||||
statusLog Json[]
|
||||
eventId Int
|
||||
model EventAppointment {
|
||||
id Int @id @default(autoincrement())
|
||||
eventId Int
|
||||
appointmentDate DateTime
|
||||
presenterId String
|
||||
// relations:
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
Event Event? @relation(fields: [eventId], references: [id])
|
||||
Users User[] @relation("EventAppointmentUser")
|
||||
Participants Participant[]
|
||||
Event Event @relation(fields: [eventId], references: [id])
|
||||
Presenter User @relation(fields: [presenterId], references: [id])
|
||||
}
|
||||
|
||||
model Participant {
|
||||
id Int @id @default(autoincrement())
|
||||
userId String @map(name: "user_id")
|
||||
starterMoodleCurseCompleted Boolean @default(false)
|
||||
finisherMoodleCurseCompleted Boolean @default(false)
|
||||
eventAppointmentId Int?
|
||||
statusLog Json[]
|
||||
eventId Int
|
||||
// relations:
|
||||
User User @relation(fields: [userId], references: [id])
|
||||
Event Event @relation(fields: [eventId], references: [id])
|
||||
EventAppointment EventAppointment? @relation(fields: [eventAppointmentId], references: [id])
|
||||
}
|
||||
|
||||
model Event {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
description String
|
||||
discordRoleId String?
|
||||
discordRoleId String? @default("")
|
||||
hasPresenceEvents Boolean @default(false)
|
||||
maxParticipants Int? @default(0)
|
||||
starterMoodleCourseId Int?
|
||||
finisherMoodleCourseId Int?
|
||||
starterMoodleCourseId String? @default("")
|
||||
finisherMoodleCourseId String? @default("")
|
||||
finishedBadges String[] @default([])
|
||||
requiredBadges String[] @default([])
|
||||
finishedPermissions String[] @default([])
|
||||
@@ -38,6 +52,7 @@ model Event {
|
||||
|
||||
// relations:
|
||||
participants Participant[]
|
||||
appointments EventAppointment[]
|
||||
}
|
||||
|
||||
model File {
|
||||
|
||||
@@ -1,20 +1,42 @@
|
||||
enum BADGES {
|
||||
P1
|
||||
P2
|
||||
P3
|
||||
D1
|
||||
D2
|
||||
D3
|
||||
DAY1
|
||||
}
|
||||
|
||||
enum PERMISSION {
|
||||
ADMIN_EVENT
|
||||
ADMIN_USER
|
||||
SUSPENDED
|
||||
PILOT
|
||||
DISPO
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
publicId String @unique
|
||||
id String @id @default(uuid())
|
||||
publicId String @unique
|
||||
firstname String
|
||||
lastname String
|
||||
email String @unique
|
||||
email String @unique
|
||||
password String
|
||||
vatsimCid Int? @map(name: "vatsim_cid")
|
||||
emailVerified DateTime? @map(name: "email_verified")
|
||||
vatsimCid Int? @map(name: "vatsim_cid")
|
||||
emailVerified DateTime? @map(name: "email_verified")
|
||||
image String?
|
||||
createdAt DateTime @default(now()) @map(name: "created_at")
|
||||
updatedAt DateTime @default(now()) @map(name: "updated_at")
|
||||
badges BADGES[] @default([])
|
||||
permissions PERMISSION[] @default([])
|
||||
createdAt DateTime @default(now()) @map(name: "created_at")
|
||||
updatedAt DateTime @default(now()) @map(name: "updated_at")
|
||||
|
||||
// relations:
|
||||
oauthTokens OAuthToken[]
|
||||
discordAccounts DiscordAccount[]
|
||||
participants Participant[]
|
||||
oauthTokens OAuthToken[]
|
||||
discordAccounts DiscordAccount[]
|
||||
participants Participant[]
|
||||
EventAppointmentUser EventAppointment[] @relation("EventAppointmentUser")
|
||||
EventAppointment EventAppointment[]
|
||||
|
||||
@@map(name: "users")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user