add salmon run tables migration

This commit is contained in:
Kalle (Sendou)
2020-12-14 17:58:46 +02:00
parent 9c4bb1ce95
commit 25ffda52c4
3 changed files with 118 additions and 11 deletions

View File

@@ -6,9 +6,9 @@
"dev": "next dev",
"build": "lingui compile && next build",
"start": "next start",
"migrate": "prisma migrate dev --preview-feature",
"migrate:save": "npx prisma migrate save --name init --experimental",
"migrate:up": "npx prisma migrate up --experimental",
"migrate": "prisma migrate deploy --preview-feature",
"migrate:save": "prisma migrate dev --create-only --preview-feature",
"migrate:up": "prisma migrate dev --preview-feature",
"studio": "npx prisma studio",
"gen": "npx prisma generate",
"seed": "ts-node prisma/seed.ts",

View File

@@ -0,0 +1,50 @@
-- CreateEnum
CREATE TYPE "public"."SalmonRunRecordCategory" AS ENUM ('TOTAL', 'TOTAL_NO_NIGHT', 'PRINCESS', 'NT_NORMAL', 'HT_NORMAL', 'LT_NORMAL', 'NT_RUSH', 'HT_RUSH', 'NT_FOG', 'HT_FOG', 'LT_FOG', 'NT_GOLDIE', 'HT_GOLDIE', 'NT_GRILLERS', 'HT_GRILLERS', 'NT_MOTHERSHIP', 'HT_MOTHERSHIP', 'LT_MOTHERSHIP', 'LT_COHOCK');
-- CreateTable
CREATE TABLE "SalmonRunRotation" (
"id" INTEGER NOT NULL,
"startTime" TIMESTAMP(3) NOT NULL,
"endTime" TIMESTAMP(3) NOT NULL,
"weapons" TEXT[],
"grizzcoWeapon" TEXT,
"stage" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "SalmonRunRecord" (
"id" SERIAL,
"rotationId" INTEGER NOT NULL,
"submitterId" INTEGER NOT NULL,
"goldenEggCount" INTEGER NOT NULL,
"approved" BOOLEAN NOT NULL,
"category" "SalmonRunRecordCategory" NOT NULL,
"links" TEXT[],
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "SalmonRunPlayer" (
"recordId" INTEGER NOT NULL,
"userId" INTEGER NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "SalmonRunRotation.id_unique" ON "SalmonRunRotation"("id");
-- CreateIndex
CREATE UNIQUE INDEX "SalmonRunPlayer.recordId_userId_unique" ON "SalmonRunPlayer"("recordId", "userId");
-- AddForeignKey
ALTER TABLE "SalmonRunRecord" ADD FOREIGN KEY("rotationId")REFERENCES "SalmonRunRotation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "SalmonRunRecord" ADD FOREIGN KEY("submitterId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "SalmonRunPlayer" ADD FOREIGN KEY("recordId")REFERENCES "SalmonRunRecord"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "SalmonRunPlayer" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -9,14 +9,16 @@ generator client {
}
model User {
id Int @id @default(autoincrement())
username String
discriminator String
discordId String @unique
discordAvatar String?
profile Profile?
player Player?
builds Build[]
id Int @id @default(autoincrement())
username String
discriminator String
discordId String @unique
discordAvatar String?
profile Profile?
player Player?
builds Build[]
submittedRecords SalmonRunRecord[]
salmonRunRecords SalmonRunPlayer[]
}
model Profile {
@@ -157,3 +159,58 @@ model Build {
@@index(userId)
@@index(abilityPoints)
}
model SalmonRunRotation {
id Int @unique
startTime DateTime
endTime DateTime
weapons String[]
grizzcoWeapon String?
stage String
records SalmonRunRecord[]
}
enum SalmonRunRecordCategory {
TOTAL
TOTAL_NO_NIGHT
PRINCESS
NT_NORMAL
HT_NORMAL
LT_NORMAL
NT_RUSH
HT_RUSH
NT_FOG
HT_FOG
LT_FOG
NT_GOLDIE
HT_GOLDIE
NT_GRILLERS
HT_GRILLERS
NT_MOTHERSHIP
HT_MOTHERSHIP
LT_MOTHERSHIP
LT_COHOCK
}
model SalmonRunRecord {
id Int @id @default(autoincrement())
rotationId Int
submitterId Int
goldenEggCount Int
approved Boolean
category SalmonRunRecordCategory
links String[]
createdAt DateTime @default(now())
rotation SalmonRunRotation @relation(fields: [rotationId], references: [id])
submitter User @relation(fields: [submitterId], references: [id])
players SalmonRunPlayer[]
}
model SalmonRunPlayer {
recordId Int
userId Int
record SalmonRunRecord @relation(fields: [recordId], references: [id])
user User @relation(fields: [userId], references: [id])
@@unique([recordId, userId])
}