first migrate

This commit is contained in:
Kalle (Sendou)
2020-10-13 17:50:38 +03:00
parent 91ab25b655
commit 1084c07c4a
7 changed files with 480 additions and 1 deletions

77
package-lock.json generated
View File

@@ -1356,6 +1356,12 @@
}
}
},
"@prisma/cli": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/@prisma/cli/-/cli-2.8.1.tgz",
"integrity": "sha512-mEGJplClGnXI5ki4R0Xq8nq62zcyu7Wzdhybege+cFPZFUbFj0petaPZl/tqta9o5neDyvpU/lDgOwef6mwySg==",
"dev": true
},
"@protobufjs/aspromise": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
@@ -2865,6 +2871,17 @@
}
}
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
}
},
"crypto-browserify": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz",
@@ -3147,6 +3164,30 @@
}
}
},
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==",
"dev": true
},
"dotenv-cli": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-4.0.0.tgz",
"integrity": "sha512-ByKEec+ashePEXthZaA1fif9XDtcaRnkN7eGdBDx3HHRjwZ/rA1go83Cbs4yRrx3JshsCf96FjAyIA2M672+CQ==",
"dev": true,
"requires": {
"cross-spawn": "^7.0.1",
"dotenv": "^8.1.0",
"dotenv-expand": "^5.1.0",
"minimist": "^1.1.3"
}
},
"dotenv-expand": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz",
"integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==",
"dev": true
},
"duplexify": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz",
@@ -4122,6 +4163,12 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
},
"isobject": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
@@ -4942,6 +4989,12 @@
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
@@ -5613,6 +5666,21 @@
"safe-buffer": "^5.0.1"
}
},
"shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"requires": {
"shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
"shell-quote": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz",
@@ -6720,6 +6788,15 @@
"webidl-conversions": "^4.0.2"
}
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
},
"worker-farm": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz",

View File

@@ -5,7 +5,10 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
"start": "next start",
"migrate:save": "dotenv -e .env.local -- npx prisma migrate save --name init --experimental",
"migrate:up": "dotenv -e .env.local -- npx prisma migrate up --experimental",
"studio": "dotenv -e .env.local -- npx prisma studio"
},
"dependencies": {
"@nexus/schema": "^0.16.0",
@@ -16,7 +19,9 @@
"react-dom": "16.13.1"
},
"devDependencies": {
"@prisma/cli": "^2.8.1",
"@types/react": "^16.9.49",
"dotenv-cli": "^4.0.0",
"typescript": "^4.0.3"
}
}

View File

@@ -0,0 +1,79 @@
# Migration `20201013141255-init`
This migration has been generated by Kalle (Sendou) at 10/13/2020, 5:12:55 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "public"."User" (
"id" SERIAL,
"username" text NOT NULL ,
"discriminator" text NOT NULL ,
"discordId" text NOT NULL ,
"discordAvatar" text ,
PRIMARY KEY ("id")
)
CREATE TABLE "public"."Profile" (
"twitchName" text ,
"youtubeId" text ,
"country" text ,
"sensMotion" integer ,
"sensStick" integer ,
"bio" text ,
"weaponPool" text [] ,
"customUrlPath" text ,
"userId" integer NOT NULL
)
CREATE UNIQUE INDEX "User.discordId_unique" ON "public"."User"("discordId")
CREATE UNIQUE INDEX "Profile.customUrlPath_unique" ON "public"."Profile"("customUrlPath")
CREATE UNIQUE INDEX "Profile.userId_unique" ON "public"."Profile"("userId")
ALTER TABLE "public"."Profile" ADD FOREIGN KEY ("userId")REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration ..20201013141255-init
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,30 @@
+datasource db {
+ provider = "postgresql"
+ 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?
+}
+
+model Profile {
+ twitchName String?
+ youtubeId String?
+ country String?
+ sensMotion Int?
+ sensStick Int?
+ bio String?
+ weaponPool String[]
+ customUrlPath String? @unique
+ user User @relation(fields: [userId], references: [id])
+ userId Int @unique
+}
```

View File

@@ -0,0 +1,30 @@
datasource db {
provider = "postgresql"
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?
}
model Profile {
twitchName String?
youtubeId String?
country String?
sensMotion Int?
sensStick Int?
bio String?
weaponPool String[]
customUrlPath String? @unique
user User @relation(fields: [userId], references: [id])
userId Int @unique
}

View File

@@ -0,0 +1,255 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"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": "CreateModel",
"model": "Profile"
},
{
"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": "Int",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Profile",
"field": "sensStick",
"type": "Int",
"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"
}
}
]
}

View File

@@ -0,0 +1,3 @@
# Prisma Migrate lockfile v1
20201013141255-init

30
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,30 @@
datasource db {
provider = "postgresql"
url = env("DATABASE_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?
}
model Profile {
twitchName String?
youtubeId String?
country String?
sensMotion Int?
sensStick Int?
bio String?
weaponPool String[]
customUrlPath String? @unique
user User @relation(fields: [userId], references: [id])
userId Int @unique
}