diff --git a/prisma/migrations/20241026030526_participant_disqualifications/migration.sql b/prisma/migrations/20241026030526_participant_disqualifications/migration.sql new file mode 100644 index 0000000..a9ea386 --- /dev/null +++ b/prisma/migrations/20241026030526_participant_disqualifications/migration.sql @@ -0,0 +1,30 @@ +/* + Warnings: + + - You are about to drop the column `disqualified` on the `ContestantParticipation` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "ContestantParticipation" DROP COLUMN "disqualified"; + +-- CreateTable +CREATE TABLE "Disqualification" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "ofmiId" TEXT NOT NULL, + "reason" TEXT NOT NULL, + "appealed" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Disqualification_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Disqualification_userId_ofmiId_key" ON "Disqualification"("userId", "ofmiId"); + +-- AddForeignKey +ALTER TABLE "Disqualification" ADD CONSTRAINT "Disqualification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Disqualification" ADD CONSTRAINT "Disqualification_ofmiId_fkey" FOREIGN KEY ("ofmiId") REFERENCES "Ofmi"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20241114064745_disqualificationid_and_contestantparticipationid/migration.sql b/prisma/migrations/20241114064745_disqualificationid_and_contestantparticipationid/migration.sql new file mode 100644 index 0000000..6fb2fc1 --- /dev/null +++ b/prisma/migrations/20241114064745_disqualificationid_and_contestantparticipationid/migration.sql @@ -0,0 +1,29 @@ +/* + Warnings: + + - You are about to drop the column `ofmiId` on the `Disqualification` table. All the data in the column will be lost. + - You are about to drop the column `userId` on the `Disqualification` table. All the data in the column will be lost. + - A unique constraint covering the columns `[DisqualificationId]` on the table `ContestantParticipation` will be added. If there are existing duplicate values, this will fail. + +*/ +-- DropForeignKey +ALTER TABLE "Disqualification" DROP CONSTRAINT "Disqualification_ofmiId_fkey"; + +-- DropForeignKey +ALTER TABLE "Disqualification" DROP CONSTRAINT "Disqualification_userId_fkey"; + +-- DropIndex +DROP INDEX "Disqualification_userId_ofmiId_key"; + +-- AlterTable +ALTER TABLE "ContestantParticipation" ADD COLUMN "DisqualificationId" TEXT; + +-- AlterTable +ALTER TABLE "Disqualification" DROP COLUMN "ofmiId", +DROP COLUMN "userId"; + +-- CreateIndex +CREATE UNIQUE INDEX "ContestantParticipation_DisqualificationId_key" ON "ContestantParticipation"("DisqualificationId"); + +-- AddForeignKey +ALTER TABLE "ContestantParticipation" ADD CONSTRAINT "ContestantParticipation_DisqualificationId_fkey" FOREIGN KEY ("DisqualificationId") REFERENCES "Disqualification"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index fa82f68..c72cac1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -150,21 +150,24 @@ model Participation { } model ContestantParticipation { - id String @id @default(uuid()) - schoolId String - School School @relation(fields: [schoolId], references: [id]) - schoolGrade Int - medal String? - place Int? - disqualified Boolean - omegaupUserId String? - omegaupUser OmegaupUser? @relation(fields: [omegaupUserId], references: [id]) - problemResults ProblemResult[] - Participation Participation[] - Mentorias Mentoria[] - File File[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(uuid()) + schoolId String + School School @relation(fields: [schoolId], references: [id]) + schoolGrade Int + medal String? + place Int? + omegaupUserId String? + omegaupUser OmegaupUser? @relation(fields: [omegaupUserId], references: [id]) + problemResults ProblemResult[] + Participation Participation[] + File File[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + Disqualification Disqualification? @relation(fields: [DisqualificationId], references: [id]) + DisqualificationId String? + Mentoria Mentoria[] + + @@unique([DisqualificationId]) } model VolunteerParticipation { @@ -241,3 +244,12 @@ model OmegaupUser { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } + +model Disqualification { + id String @id @default(uuid()) + reason String + appealed Boolean @default(false) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + ContestantParticipation ContestantParticipation? +} diff --git a/src/components/admin/index.tsx b/src/components/admin/index.tsx index 4d33413..92d9ab9 100644 --- a/src/components/admin/index.tsx +++ b/src/components/admin/index.tsx @@ -88,7 +88,6 @@ export default function Admin(): JSX.Element { ); }} > - {Object.keys(APIS).map((name) => (