From fe6e8a50f2cdef1fb5b63b5648a6b5033d62f6bd Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Wed, 9 Mar 2022 00:15:43 +0200 Subject: [PATCH] Fix migration --- app/routes/match-details.ts | 2 +- .../migration.sql | 8 +++++--- prisma/schema.prisma | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) rename prisma/migrations/{20220307165333_add_details => 20220308221343_add_details}/migration.sql (83%) diff --git a/app/routes/match-details.ts b/app/routes/match-details.ts index 333a66b0b..5e784a439 100644 --- a/app/routes/match-details.ts +++ b/app/routes/match-details.ts @@ -106,7 +106,7 @@ export const action: ActionFunction = async ({ request }) => { for (const [i, map] of input.data.maps.entries()) { const lfgStage = match.stages[i]; - invariant(lfgStage, "Unexpected lfgStage undefined"); + invariant(lfgStage?.id, "Unexpected lfgStage undefined"); createGameDetailsInput.push({ id: uuidv4(), diff --git a/prisma/migrations/20220307165333_add_details/migration.sql b/prisma/migrations/20220308221343_add_details/migration.sql similarity index 83% rename from prisma/migrations/20220307165333_add_details/migration.sql rename to prisma/migrations/20220308221343_add_details/migration.sql index d75cc2079..fa864f282 100644 --- a/prisma/migrations/20220307165333_add_details/migration.sql +++ b/prisma/migrations/20220308221343_add_details/migration.sql @@ -1,15 +1,14 @@ /* Warnings: - - The required column `id` was added to the `LfgGroupMatchStage` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required. + - A unique constraint covering the columns `[id]` on the table `LfgGroupMatchStage` will be added. If there are existing duplicate values, this will fail. */ -- CreateEnum CREATE TYPE "Ability" AS ENUM ('CB', 'LDE', 'OG', 'T', 'H', 'NS', 'TI', 'RP', 'AD', 'DR', 'SJ', 'OS', 'BDU', 'REC', 'RES', 'ISM', 'ISS', 'MPU', 'QR', 'QSJ', 'RSU', 'SSU', 'SCU', 'SPU', 'SS', 'BRU', 'EMPTY'); -- AlterTable -ALTER TABLE "LfgGroupMatchStage" ADD COLUMN "id" TEXT NOT NULL, -ADD CONSTRAINT "LfgGroupMatchStage_pkey" PRIMARY KEY ("id"); +ALTER TABLE "LfgGroupMatchStage" ADD COLUMN "id" TEXT; -- AlterTable ALTER TABLE "User" ADD COLUMN "bannedUntil" TIMESTAMP(3); @@ -58,6 +57,9 @@ CREATE UNIQUE INDEX "GameDetail_lfgStageId_key" ON "GameDetail"("lfgStageId"); -- CreateIndex CREATE UNIQUE INDEX "GameDetailTeam_gameDetailId_isWinner_key" ON "GameDetailTeam"("gameDetailId", "isWinner"); +-- CreateIndex +CREATE UNIQUE INDEX "LfgGroupMatchStage_id_key" ON "LfgGroupMatchStage"("id"); + -- AddForeignKey ALTER TABLE "GameDetail" ADD CONSTRAINT "GameDetail_lfgStageId_fkey" FOREIGN KEY ("lfgStageId") REFERENCES "LfgGroupMatchStage"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 31019c71f..ff0ce7455 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -273,7 +273,8 @@ model LfgGroupMatch { } model LfgGroupMatchStage { - id String @id @default(uuid()) + // TODO: this should be a required id field + id String? @unique @default(uuid()) lfgGroupMatchId String stageId Int order Int