From 5f70d59ab8809272daffd73ce43a3e26d998a94c Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Mon, 14 Dec 2020 14:14:34 +0200 Subject: [PATCH] prisma migrate preview --- package-lock.json | 28 +- package.json | 5 +- .../migrations/20201205144602-init/README.md | 293 ----- .../20201205144602-init/schema.prisma | 159 --- .../migrations/20201205144602-init/steps.json | 1106 ----------------- .../20201214111511_initial/migration.sql | 152 +++ prisma/migrations/migrate.lock | 3 - 7 files changed, 169 insertions(+), 1577 deletions(-) delete mode 100644 prisma/migrations/20201205144602-init/README.md delete mode 100644 prisma/migrations/20201205144602-init/schema.prisma delete mode 100644 prisma/migrations/20201205144602-init/steps.json create mode 100644 prisma/migrations/20201214111511_initial/migration.sql delete mode 100644 prisma/migrations/migrate.lock diff --git a/package-lock.json b/package-lock.json index 094c5af52..777bc2c37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1666,33 +1666,33 @@ "dev": true }, "@prisma/cli": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/@prisma/cli/-/cli-2.12.1.tgz", - "integrity": "sha512-obkwK95dEeifCdVehG0rS0BlPQGLsOtc9U1MgbrjNX3MnhXQdwROnvymfPB3DBlNyoLoHGklPgi9UlwBokNXcQ==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/@prisma/cli/-/cli-2.13.0.tgz", + "integrity": "sha512-1hTj9H6gVIH5J5GPQVfeHiYFxUv09HVoThGr0Z2ds4JkVMRw///ZXll7pQJvaF7DUheg7dCNf+AXvwmpfm75tg==", "dev": true, "requires": { "@prisma/bar": "^0.0.1", - "@prisma/engines": "2.12.0-18.cf0680a1bfe8d5e743dc659cc7f08009f9587d58" + "@prisma/engines": "2.13.0-32.833ab05d2a20e822f6736a39a27de4fc8f6b3e49" } }, "@prisma/client": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-2.12.1.tgz", - "integrity": "sha512-HP4/E9sRdxw/FB7XP4EeRa5ri8Lp1U/L7G4VAA95aM8C+8ARioQHMNDpEjC83NrOrOr4EcaZV5pXDDQL1H+F0g==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-2.13.0.tgz", + "integrity": "sha512-osu9oRFWYNU3s+khj7D0xn28yGbk9nUWPG6VYDGIisBf0OTDB3STisCa0O0k5rzk1GpdxLiGJaHpqIo40RkMLw==", "requires": { - "@prisma/engines-version": "2.12.0-18.cf0680a1bfe8d5e743dc659cc7f08009f9587d58" + "@prisma/engines-version": "2.13.0-32.833ab05d2a20e822f6736a39a27de4fc8f6b3e49" } }, "@prisma/engines": { - "version": "2.12.0-18.cf0680a1bfe8d5e743dc659cc7f08009f9587d58", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-2.12.0-18.cf0680a1bfe8d5e743dc659cc7f08009f9587d58.tgz", - "integrity": "sha512-F6RmUZ5JpPWxmGvVDji8c4gepHIGkvYbtuFi0IoDDJVaCVo8yS656stciKFyswI6/BLWXa0X47/MIMbz6nzw7g==", + "version": "2.13.0-32.833ab05d2a20e822f6736a39a27de4fc8f6b3e49", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-2.13.0-32.833ab05d2a20e822f6736a39a27de4fc8f6b3e49.tgz", + "integrity": "sha512-BntRdj/uJQMPRXzcYJv80+NtMq+m6f+PIcCTzOUqKerEo53+ynm4bHo2ocLRLS4XtWovGummDlVgZxgWTRhkAw==", "dev": true }, "@prisma/engines-version": { - "version": "2.12.0-18.cf0680a1bfe8d5e743dc659cc7f08009f9587d58", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-2.12.0-18.cf0680a1bfe8d5e743dc659cc7f08009f9587d58.tgz", - "integrity": "sha512-IHb/Jag1Wmoq5tLZhOHP5zqLHEXqQEfrHb6l0drIBSvh2AF7yWQ3yyuD0ZEb1Nq37SvbBgop5wrWMOU8YWFTGQ==" + "version": "2.13.0-32.833ab05d2a20e822f6736a39a27de4fc8f6b3e49", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-2.13.0-32.833ab05d2a20e822f6736a39a27de4fc8f6b3e49.tgz", + "integrity": "sha512-OsToEhPo8OKOW2RmfjrQs1WRWX6omTsrBVMQLYKR7p3ijNBXFjCw9fk4x5xcnLZvADYR/rUIxjEK2YR+r/RK3w==" }, "@reach/alert": { "version": "0.11.0", diff --git a/package.json b/package.json index be7e5f6ac..ac891cda1 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "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", "studio": "npx prisma studio", @@ -30,7 +31,7 @@ "@emotion/styled": "^11.0.0", "@hookform/resolvers": "^1.1.2", "@lingui/react": "^3.3.0", - "@prisma/client": "^2.12.1", + "@prisma/client": "^2.13.0", "@sendou/react-sketch": "^0.5.2", "countries-list": "^2.5.6", "framer-motion": "^2.9.5", @@ -57,7 +58,7 @@ "@babel/core": "^7.12.10", "@lingui/cli": "^3.3.0", "@lingui/macro": "^3.3.0", - "@prisma/cli": "^2.12.1", + "@prisma/cli": "^2.13.0", "@types/next-auth": "^3.1.18", "@types/node": "^14.14.13", "@types/nprogress": "^0.2.0", diff --git a/prisma/migrations/20201205144602-init/README.md b/prisma/migrations/20201205144602-init/README.md deleted file mode 100644 index d0c7e2feb..000000000 --- a/prisma/migrations/20201205144602-init/README.md +++ /dev/null @@ -1,293 +0,0 @@ -# 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](./schema.prisma) after the migration. - -## Database Steps - -```sql -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 -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) -+} -``` - - diff --git a/prisma/migrations/20201205144602-init/schema.prisma b/prisma/migrations/20201205144602-init/schema.prisma deleted file mode 100644 index 0d62b9f86..000000000 --- a/prisma/migrations/20201205144602-init/schema.prisma +++ /dev/null @@ -1,159 +0,0 @@ -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) -} diff --git a/prisma/migrations/20201205144602-init/steps.json b/prisma/migrations/20201205144602-init/steps.json deleted file mode 100644 index 71e0b3be1..000000000 --- a/prisma/migrations/20201205144602-init/steps.json +++ /dev/null @@ -1,1106 +0,0 @@ -{ - "version": "0.3.14-fixed", - "steps": [ - { - "tag": "CreateEnum", - "enum": "RankedMode", - "values": [ - "SZ", - "TC", - "RM", - "CB" - ] - }, - { - "tag": "CreateEnum", - "enum": "Mode", - "values": [ - "TW", - "SZ", - "TC", - "RM", - "CB" - ] - }, - { - "tag": "CreateEnum", - "enum": "Region", - "values": [ - "EU", - "NA", - "JP" - ] - }, - { - "tag": "CreateEnum", - "enum": "LeagueType", - "values": [ - "TWIN", - "QUAD" - ] - }, - { - "tag": "CreateEnum", - "enum": "Ability", - "values": [ - "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" - ] - }, - { - "tag": "CreateSource", - "source": "db" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Source", - "source": "db" - }, - "argument": "provider", - "value": "\"postgresql\"" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Source", - "source": "db" - }, - "argument": "url", - "value": "\"***\"" - }, - { - "tag": "CreateModel", - "model": "User" - }, - { - "tag": "CreateField", - "model": "User", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateField", - "model": "User", - "field": "username", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "User", - "field": "discriminator", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "User", - "field": "discordId", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "discordId" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "User", - "field": "discordAvatar", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "profile", - "type": "Profile", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "player", - "type": "Player", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "builds", - "type": "Build", - "arity": "List" - }, - { - "tag": "CreateModel", - "model": "Profile" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "twitterName", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "twitchName", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "youtubeId", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "country", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "sensMotion", - "type": "Float", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "sensStick", - "type": "Float", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "bio", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "weaponPool", - "type": "String", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "customUrlPath", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Profile", - "field": "customUrlPath" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "user", - "type": "User", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Profile", - "field": "user" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Profile", - "field": "user" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[userId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Profile", - "field": "user" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateField", - "model": "Profile", - "field": "userId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Profile", - "field": "userId" - }, - "directive": "unique" - } - }, - { - "tag": "CreateModel", - "model": "XRankPlacement" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "XRankPlacement", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "XRankPlacement", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "XRankPlacement", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "switchAccountId", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "player", - "type": "Player", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "XRankPlacement", - "field": "player" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "XRankPlacement", - "field": "player" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[switchAccountId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "XRankPlacement", - "field": "player" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[switchAccountId]" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "playerName", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "ranking", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "xPower", - "type": "Float", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "weapon", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "mode", - "type": "RankedMode", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "month", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "XRankPlacement", - "field": "year", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "XRankPlacement", - "arguments": [ - { - "name": "", - "value": "[switchAccountId, mode, month, year]" - } - ] - }, - "directive": "unique" - } - }, - { - "tag": "CreateModel", - "model": "LeagueSquad" - }, - { - "tag": "CreateField", - "model": "LeagueSquad", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "LeagueSquad", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "LeagueSquad", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "LeagueSquad", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateField", - "model": "LeagueSquad", - "field": "region", - "type": "Region", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "LeagueSquad", - "field": "type", - "type": "LeagueType", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "LeagueSquad", - "field": "leaguePower", - "type": "Float", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "LeagueSquad", - "field": "startTime", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "LeagueSquad", - "field": "members", - "type": "LeagueSquadMember", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "LeagueSquad", - "arguments": [ - { - "name": "", - "value": "[leaguePower, type, region]" - } - ] - }, - "directive": "index" - } - }, - { - "tag": "CreateModel", - "model": "LeagueSquadMember" - }, - { - "tag": "CreateField", - "model": "LeagueSquadMember", - "field": "squadId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "LeagueSquadMember", - "field": "squad", - "type": "LeagueSquad", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "LeagueSquadMember", - "field": "squad" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "LeagueSquadMember", - "field": "squad" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[squadId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "LeagueSquadMember", - "field": "squad" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateField", - "model": "LeagueSquadMember", - "field": "switchAccountId", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "LeagueSquadMember", - "field": "player", - "type": "Player", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "LeagueSquadMember", - "field": "player" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "LeagueSquadMember", - "field": "player" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[switchAccountId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "LeagueSquadMember", - "field": "player" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[switchAccountId]" - }, - { - "tag": "CreateField", - "model": "LeagueSquadMember", - "field": "weapon", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "LeagueSquadMember", - "arguments": [ - { - "name": "", - "value": "[squadId, switchAccountId]" - } - ] - }, - "directive": "unique" - } - }, - { - "tag": "CreateModel", - "model": "Player" - }, - { - "tag": "CreateField", - "model": "Player", - "field": "switchAccountId", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Player", - "field": "switchAccountId" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "Player", - "field": "userId", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Player", - "field": "userId" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "Player", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Player", - "field": "placements", - "type": "XRankPlacement", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Player", - "field": "user", - "type": "User", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Player", - "field": "user" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Player", - "field": "user" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[userId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Player", - "field": "user" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateField", - "model": "Player", - "field": "leaguePlacements", - "type": "LeagueSquadMember", - "arity": "List" - }, - { - "tag": "CreateModel", - "model": "Build" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Build", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Build", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Build", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "userId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "weapon", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "title", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "description", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "modes", - "type": "Mode", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "headGear", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "headAbilities", - "type": "Ability", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "clothingGear", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "clothingAbilities", - "type": "Ability", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "shoesGear", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "shoesAbilities", - "type": "Ability", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "abilityPoints", - "type": "Json", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "top500", - "type": "Boolean", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "jpn", - "type": "Boolean", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "Build", - "field": "updatedAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Build", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Build", - "field": "user", - "type": "User", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Build", - "field": "user" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Build", - "field": "user" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[userId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Build", - "field": "user" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Build", - "arguments": [ - { - "name": "", - "value": "weapon" - } - ] - }, - "directive": "index" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Build", - "arguments": [ - { - "name": "", - "value": "userId" - } - ] - }, - "directive": "index" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Build", - "arguments": [ - { - "name": "", - "value": "abilityPoints" - } - ] - }, - "directive": "index" - } - } - ] -} \ No newline at end of file diff --git a/prisma/migrations/20201214111511_initial/migration.sql b/prisma/migrations/20201214111511_initial/migration.sql new file mode 100644 index 000000000..b9473014b --- /dev/null +++ b/prisma/migrations/20201214111511_initial/migration.sql @@ -0,0 +1,152 @@ +-- CreateEnum +CREATE TYPE "public"."RankedMode" AS ENUM ('SZ', 'TC', 'RM', 'CB'); + +-- CreateEnum +CREATE TYPE "public"."Mode" AS ENUM ('TW', 'SZ', 'TC', 'RM', 'CB'); + +-- CreateEnum +CREATE TYPE "public"."Region" AS ENUM ('EU', 'NA', 'JP'); + +-- CreateEnum +CREATE TYPE "public"."LeagueType" AS ENUM ('TWIN', 'QUAD'); + +-- CreateEnum +CREATE TYPE "public"."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'); + +-- CreateTable +CREATE TABLE "User" ( +"id" SERIAL, + "username" TEXT NOT NULL, + "discriminator" TEXT NOT NULL, + "discordId" TEXT NOT NULL, + "discordAvatar" TEXT, + + PRIMARY KEY ("id") +); + +-- CreateTable +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 +); + +-- CreateTable +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") +); + +-- CreateTable +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") +); + +-- CreateTable +CREATE TABLE "LeagueSquadMember" ( + "squadId" INTEGER NOT NULL, + "switchAccountId" TEXT NOT NULL, + "weapon" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "Player" ( + "switchAccountId" TEXT NOT NULL, + "userId" INTEGER, + "name" TEXT +); + +-- CreateTable +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") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User.discordId_unique" ON "User"("discordId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Profile.customUrlPath_unique" ON "Profile"("customUrlPath"); + +-- CreateIndex +CREATE UNIQUE INDEX "Profile.userId_unique" ON "Profile"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "XRankPlacement.switchAccountId_mode_month_year_unique" ON "XRankPlacement"("switchAccountId", "mode", "month", "year"); + +-- CreateIndex +CREATE INDEX "LeagueSquad.leaguePower_type_region_index" ON "LeagueSquad"("leaguePower", "type", "region"); + +-- CreateIndex +CREATE UNIQUE INDEX "LeagueSquadMember.squadId_switchAccountId_unique" ON "LeagueSquadMember"("squadId", "switchAccountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Player.switchAccountId_unique" ON "Player"("switchAccountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Player.userId_unique" ON "Player"("userId"); + +-- CreateIndex +CREATE INDEX "Build.weapon_index" ON "Build"("weapon"); + +-- CreateIndex +CREATE INDEX "Build.userId_index" ON "Build"("userId"); + +-- CreateIndex +CREATE INDEX "Build.abilityPoints_index" ON "Build"("abilityPoints"); + +-- AddForeignKey +ALTER TABLE "Profile" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "XRankPlacement" ADD FOREIGN KEY("switchAccountId")REFERENCES "Player"("switchAccountId") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "LeagueSquadMember" ADD FOREIGN KEY("squadId")REFERENCES "LeagueSquad"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "LeagueSquadMember" ADD FOREIGN KEY("switchAccountId")REFERENCES "Player"("switchAccountId") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Player" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Build" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/migrate.lock b/prisma/migrations/migrate.lock deleted file mode 100644 index 3e7bcf224..000000000 --- a/prisma/migrations/migrate.lock +++ /dev/null @@ -1,3 +0,0 @@ -# Prisma Migrate lockfile v1 - -20201205144602-init \ No newline at end of file