From ca4caec3078e122b3b6aac41a5eea7e8da56ca6e Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Sat, 6 Feb 2021 13:14:26 +0200 Subject: [PATCH] unique id to principal migration --- .../migration.sql | 20 +++++++++++++++++++ prisma/schema.prisma | 6 ++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 prisma/migrations/20210206111138_unique_to_principal_detailed/migration.sql diff --git a/prisma/migrations/20210206111138_unique_to_principal_detailed/migration.sql b/prisma/migrations/20210206111138_unique_to_principal_detailed/migration.sql new file mode 100644 index 000000000..c77dde064 --- /dev/null +++ b/prisma/migrations/20210206111138_unique_to_principal_detailed/migration.sql @@ -0,0 +1,20 @@ +/* + Warnings: + + - You are about to drop the column `uniqueId` on the `DetailedMapPlayer` table. All the data in the column will be lost. + - The migration will add a unique constraint covering the columns `[detailedMapId,principalId]` on the table `DetailedMapPlayer`. If there are existing duplicate values, the migration will fail. + - Added the required column `principalId` to the `DetailedMapPlayer` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropIndex +DROP INDEX "DetailedMapPlayer.detailedMapId_uniqueId_unique"; + +-- DropForeignKey +ALTER TABLE "DetailedMapPlayer" DROP CONSTRAINT "DetailedMapPlayer_uniqueId_fkey"; + +-- AlterTable +ALTER TABLE "DetailedMapPlayer" DROP COLUMN "uniqueId", +ADD COLUMN "principalId" TEXT NOT NULL; + +-- CreateIndex +CREATE UNIQUE INDEX "DetailedMapPlayer.detailedMapId_principalId_unique" ON "DetailedMapPlayer"("detailedMapId", "principalId"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 606dc8f58..79e331afc 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -114,7 +114,6 @@ model Player { placements XRankPlacement[] user User? @relation(fields: [userId], references: [id]) leaguePlacements LeagueSquadMember[] - detailedMapInfos DetailedMapPlayer[] @@index([principalId]) } @@ -324,7 +323,7 @@ enum WinnerLoser { model DetailedMapPlayer { detailedMapId Int status WinnerLoser - uniqueId String + principalId String name String weapon String mainAbilities Ability[] @@ -335,8 +334,7 @@ model DetailedMapPlayer { specials Int paint Int gear String[] - player Player @relation(fields: [uniqueId], references: [switchAccountId]) detailedMap DetailedMap @relation(fields: [detailedMapId], references: [id]) - @@unique([detailedMapId, uniqueId]) + @@unique([detailedMapId, principalId]) }