unique id to principal migration

This commit is contained in:
Kalle (Sendou)
2021-02-06 13:14:26 +02:00
parent 7b969c27dd
commit ca4caec307
2 changed files with 22 additions and 4 deletions

View File

@@ -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");

View File

@@ -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])
}