mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-11 13:15:18 -05:00
| .. | ||
| README.md | ||
| schema.prisma | ||
| steps.json | ||
Migration 20201205144602-init
This migration has been generated by Kalle (Sendou) at 12/5/2020, 4:46:02 PM. You can check out the state of the schema after the migration.
Database Steps
CREATE TABLE "User" (
"id" SERIAL,
"username" TEXT NOT NULL,
"discriminator" TEXT NOT NULL,
"discordId" TEXT NOT NULL,
"discordAvatar" TEXT,
PRIMARY KEY ("id")
)
CREATE TABLE "Profile" (
"twitterName" TEXT,
"twitchName" TEXT,
"youtubeId" TEXT,
"country" TEXT,
"sensMotion" DECIMAL(65,30),
"sensStick" DECIMAL(65,30),
"bio" TEXT,
"weaponPool" TEXT[],
"customUrlPath" TEXT,
"userId" INTEGER NOT NULL
)
CREATE TABLE "XRankPlacement" (
"id" SERIAL,
"switchAccountId" TEXT NOT NULL,
"playerName" TEXT NOT NULL,
"ranking" INTEGER NOT NULL,
"xPower" DECIMAL(65,30) NOT NULL,
"weapon" TEXT NOT NULL,
"mode" "RankedMode" NOT NULL,
"month" INTEGER NOT NULL,
"year" INTEGER NOT NULL,
PRIMARY KEY ("id")
)
CREATE TABLE "LeagueSquad" (
"id" SERIAL,
"region" "Region" NOT NULL,
"type" "LeagueType" NOT NULL,
"leaguePower" DECIMAL(65,30) NOT NULL,
"startTime" TIMESTAMP(3) NOT NULL,
PRIMARY KEY ("id")
)
CREATE TABLE "LeagueSquadMember" (
"squadId" INTEGER NOT NULL,
"switchAccountId" TEXT NOT NULL,
"weapon" TEXT NOT NULL
)
CREATE TABLE "Player" (
"switchAccountId" TEXT NOT NULL,
"userId" INTEGER,
"name" TEXT
)
CREATE TABLE "Build" (
"id" SERIAL,
"userId" INTEGER NOT NULL,
"weapon" TEXT NOT NULL,
"title" TEXT,
"description" TEXT,
"modes" "Mode"[],
"headGear" TEXT,
"headAbilities" "Ability"[],
"clothingGear" TEXT,
"clothingAbilities" "Ability"[],
"shoesGear" TEXT,
"shoesAbilities" "Ability"[],
"abilityPoints" JSONB NOT NULL,
"top500" BOOLEAN NOT NULL,
"jpn" BOOLEAN NOT NULL,
"updatedAt" TIMESTAMP(3) NOT NULL,
PRIMARY KEY ("id")
)
CREATE UNIQUE INDEX "User.discordId_unique" ON "User"("discordId")
CREATE UNIQUE INDEX "Profile.customUrlPath_unique" ON "Profile"("customUrlPath")
CREATE UNIQUE INDEX "Profile.userId_unique" ON "Profile"("userId")
CREATE UNIQUE INDEX "XRankPlacement.switchAccountId_mode_month_year_unique" ON "XRankPlacement"("switchAccountId", "mode", "month", "year")
CREATE INDEX "LeagueSquad.leaguePower_type_region_index" ON "LeagueSquad"("leaguePower", "type", "region")
CREATE UNIQUE INDEX "LeagueSquadMember.squadId_switchAccountId_unique" ON "LeagueSquadMember"("squadId", "switchAccountId")
CREATE UNIQUE INDEX "Player.switchAccountId_unique" ON "Player"("switchAccountId")
CREATE UNIQUE INDEX "Player.userId_unique" ON "Player"("userId")
CREATE INDEX "Build.weapon_index" ON "Build"("weapon")
CREATE INDEX "Build.userId_index" ON "Build"("userId")
CREATE INDEX "Build.abilityPoints_index" ON "Build"("abilityPoints")
ALTER TABLE "Profile" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE "XRankPlacement" ADD FOREIGN KEY("switchAccountId")REFERENCES "Player"("switchAccountId") ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE "LeagueSquadMember" ADD FOREIGN KEY("squadId")REFERENCES "LeagueSquad"("id") ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE "LeagueSquadMember" ADD FOREIGN KEY("switchAccountId")REFERENCES "Player"("switchAccountId") ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE "Player" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE
ALTER TABLE "Build" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
Changes
diff --git schema.prisma schema.prisma
migration ..20201205144602-init
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,159 @@
+datasource db {
+ provider = "postgresql"
+ // TODO: should use same .env system as Next.JS
+ url = "***"
+}
+
+generator client {
+ provider = "prisma-client-js"
+}
+
+model User {
+ id Int @id @default(autoincrement())
+ username String
+ discriminator String
+ discordId String @unique
+ discordAvatar String?
+ profile Profile?
+ player Player?
+ builds Build[]
+}
+
+model Profile {
+ twitterName String?
+ twitchName String?
+ youtubeId String?
+ country String?
+ sensMotion Float?
+ sensStick Float?
+ bio String?
+ weaponPool String[]
+ customUrlPath String? @unique
+ user User @relation(fields: [userId], references: [id])
+ userId Int @unique
+
+}
+
+enum RankedMode {
+ SZ
+ TC
+ RM
+ CB
+}
+
+enum Mode {
+ TW
+ SZ
+ TC
+ RM
+ CB
+}
+
+model XRankPlacement {
+ id Int @id @default(autoincrement())
+ switchAccountId String
+ player Player @relation(fields: [switchAccountId], references: [switchAccountId])
+ playerName String
+ ranking Int
+ xPower Float
+ weapon String
+ mode RankedMode
+ month Int
+ year Int
+
+ @@unique([switchAccountId, mode, month, year])
+}
+
+enum Region {
+ EU
+ NA
+ JP
+}
+
+enum LeagueType {
+ TWIN
+ QUAD
+}
+
+model LeagueSquad {
+ id Int @id @default(autoincrement())
+ region Region
+ type LeagueType
+ leaguePower Float
+ startTime DateTime
+ members LeagueSquadMember[]
+
+ @@index([leaguePower, type, region])
+}
+
+model LeagueSquadMember {
+ squadId Int
+ squad LeagueSquad @relation(fields: [squadId], references: [id])
+ switchAccountId String
+ player Player @relation(fields: [switchAccountId], references: [switchAccountId])
+ weapon String
+
+ @@unique([squadId, switchAccountId])
+}
+
+model Player {
+ switchAccountId String @unique
+ userId Int? @unique
+ name String?
+ placements XRankPlacement[]
+ user User? @relation(fields: [userId], references: [id])
+ leaguePlacements LeagueSquadMember[]
+}
+
+enum Ability {
+ 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
+}
+
+model Build {
+ id Int @id @default(autoincrement())
+ userId Int
+ weapon String
+ title String?
+ description String?
+ modes Mode[]
+ headGear String?
+ headAbilities Ability[]
+ clothingGear String?
+ clothingAbilities Ability[]
+ shoesGear String?
+ shoesAbilities Ability[]
+ abilityPoints Json
+ top500 Boolean
+ jpn Boolean
+ updatedAt DateTime @updatedAt
+ user User @relation(fields: [userId], references: [id])
+
+ @@index(weapon)
+ @@index(userId)
+ @@index(abilityPoints)
+}