Skip to content

Commit

Permalink
Merge pull request #78 from chenkie/update-prisma
Browse files Browse the repository at this point in the history
update prisma to 2.12
  • Loading branch information
nikolasburk authored Dec 4, 2020
2 parents ca0d290 + fb2b3b4 commit e0a3a21
Show file tree
Hide file tree
Showing 21 changed files with 3,785 additions and 753 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.env*
dist
package-lock.json
node_modules
.idea
.vscode
*.log
*.log
.DS_Store
2,508 changes: 2,508 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"dev": "nodemon src/index.js"
},
"dependencies": {
"@prisma/client": "^2.0.0-beta.2",
"@prisma/client": "^2.12.1",
"apollo-server": "^2.19.0",
"bcryptjs": "2.4.3",
"graphql-yoga": "1.18.3",
"jsonwebtoken": "8.5.1"
},
"devDependencies": {
"@prisma/cli": "^2.0.0-beta.2",
"nodemon": "^2.0.3"
"@prisma/cli": "^2.12.1",
"nodemon": "^2.0.6"
}
}
Binary file modified prisma/dev.db
Binary file not shown.
75 changes: 0 additions & 75 deletions prisma/migrations/20200415162823-init/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions prisma/migrations/20200415162823-init/schema.prisma

This file was deleted.

43 changes: 0 additions & 43 deletions prisma/migrations/20200415170029/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions prisma/migrations/20200415170029/steps.json

This file was deleted.

87 changes: 87 additions & 0 deletions prisma/migrations/20201125185150-init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Migration `20201125185150-init`

This migration has been generated by Ryan Chenkie at 11/25/2020, 1:51:50 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.

## Database Steps

```sql
CREATE TABLE "Link" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"description" TEXT NOT NULL,
"url" TEXT NOT NULL,
"postedById" INTEGER NOT NULL,

FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)

CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL
)

CREATE TABLE "Vote" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"linkId" INTEGER NOT NULL,
"userId" INTEGER NOT NULL,

FOREIGN KEY ("linkId") REFERENCES "Link"("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)

CREATE UNIQUE INDEX "User.email_unique" ON "User"("email")

CREATE UNIQUE INDEX "Vote.linkId_userId_unique" ON "Vote"("linkId", "userId")
```

## Changes

```diff
diff --git schema.prisma schema.prisma
migration ..20201125185150-init
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,37 @@
+datasource db {
+ provider = "sqlite"
+ url = "***"
+}
+
+generator client {
+ provider = "prisma-client-js"
+}
+
+model Link {
+ id Int @id @default(autoincrement())
+ createdAt DateTime @default(now())
+ description String
+ url String
+ postedBy User @relation(fields: [postedById], references: [id])
+ postedById Int
+ votes Vote[]
+}
+
+model User {
+ id Int @id @default(autoincrement())
+ name String
+ email String @unique
+ password String
+ links Link[]
+ votes Vote[]
+}
+
+model Vote {
+ id Int @id @default(autoincrement())
+ link Link @relation(fields: [linkId], references: [id])
+ linkId Int
+ user User @relation(fields: [userId], references: [id])
+ userId Int
+
+ @@unique([linkId, userId])
+}
```


Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"source": "db"
},
"argument": "url",
"value": "\"file:./dev.db\""
"value": "\"***\""
},
{
"tag": "CreateModel",
Expand Down Expand Up @@ -421,6 +421,22 @@
"field": "userId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Model",
"model": "Vote",
"arguments": [
{
"name": "",
"value": "[linkId, userId]"
}
]
},
"directive": "unique"
}
}
]
}
6 changes: 1 addition & 5 deletions prisma/migrations/migrate.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# IF THERE'S A GIT CONFLICT IN THIS FILE, DON'T SOLVE IT MANUALLY!
# INSTEAD EXECUTE `prisma migrate fix`
# Prisma Migrate lockfile v1
# Read more about conflict resolution here: TODO

20200415162823-init
20200415170029
20201125185150-init
Loading

0 comments on commit e0a3a21

Please sign in to comment.