This repository has been archived by the owner on Jan 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Divyendu Singh
committed
Jun 18, 2019
1 parent
efc2cd1
commit ebcae8e
Showing
10 changed files
with
284 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_modules | ||
.DS_Store | ||
|
||
dist/ | ||
*.db | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
examples/javascript/grpc/prisma/migrations/20190618162719/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Migration `20190618162719` | ||
|
||
This migration has been generated by Divyendu Singh at 6/18/2019, 4:27:19 PM. | ||
You can check out the [state of the datamodel](./datamodel.prisma) after the migration. | ||
|
||
## Database Steps | ||
|
||
```sql | ||
CREATE TABLE "file:dev"."User"("id" TEXT NOT NULL ,"email" TEXT NOT NULL DEFAULT '' ,"name" TEXT ,PRIMARY KEY ("id")); | ||
|
||
CREATE TABLE "file:dev"."Post"("id" TEXT NOT NULL ,"createdAt" DATE NOT NULL ,"updatedAt" DATE NOT NULL DEFAULT '1970-01-01 00:00:00' ,"published" BOOLEAN NOT NULL DEFAULT false ,"title" TEXT NOT NULL DEFAULT '' ,"content" TEXT ,"author" TEXT REFERENCES User(id),PRIMARY KEY ("id")); | ||
``` | ||
|
||
## Changes | ||
|
||
```diff | ||
diff --git datamodel.mdl datamodel.mdl | ||
migration ..20190618162719 | ||
--- datamodel.dml | ||
+++ datamodel.dml | ||
@@ -1,0 +1,27 @@ | ||
+datasource db { | ||
+ provider = "sqlite" | ||
+ url = "file:dev.db" | ||
+ default = true | ||
+} | ||
+ | ||
+generator photon { | ||
+ provider = "photonjs" | ||
+ output = "../node_modules/@generated/photon" | ||
+} | ||
+ | ||
+model User { | ||
+ id String @default(cuid()) @id @unique | ||
+ email String @unique | ||
+ name String? | ||
+ posts Post[] | ||
+} | ||
+ | ||
+model Post { | ||
+ id String @default(cuid()) @id @unique | ||
+ createdAt DateTime @default(now()) | ||
+ updatedAt DateTime @updatedAt | ||
+ published Boolean | ||
+ title String | ||
+ content String? | ||
+ author User? | ||
+} | ||
``` | ||
|
||
## Photon Usage | ||
|
||
You can use a specific Photon built for this migration (20190618162719) | ||
in your `before` or `after` migration script like this: | ||
|
||
```ts | ||
import Photon from '@generated/photon/20190618162719' | ||
|
||
const photon = new Photon() | ||
|
||
async function main() { | ||
const result = await photon.users() | ||
console.dir(result, { depth: null }) | ||
} | ||
|
||
main() | ||
|
||
``` |
27 changes: 27 additions & 0 deletions
27
examples/javascript/grpc/prisma/migrations/20190618162719/datamodel.prisma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
datasource db { | ||
provider = "sqlite" | ||
url = "file:dev.db" | ||
default = true | ||
} | ||
|
||
generator photon { | ||
provider = "photonjs" | ||
output = "../node_modules/@generated/photon" | ||
} | ||
|
||
model User { | ||
id String @default(cuid()) @id @unique | ||
email String @unique | ||
name String? | ||
posts Post[] | ||
} | ||
|
||
model Post { | ||
id String @default(cuid()) @id @unique | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
published Boolean | ||
title String | ||
content String? | ||
author User? | ||
} |
166 changes: 166 additions & 0 deletions
166
examples/javascript/grpc/prisma/migrations/20190618162719/steps.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
{ | ||
"version": "0.0.104", | ||
"steps": [ | ||
{ | ||
"stepType": "CreateModel", | ||
"name": "User", | ||
"embedded": false | ||
}, | ||
{ | ||
"stepType": "CreateModel", | ||
"name": "Post", | ||
"embedded": false | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "User", | ||
"name": "id", | ||
"type": { | ||
"Base": "String" | ||
}, | ||
"arity": "required", | ||
"isUnique": true, | ||
"id": { | ||
"strategy": "Auto", | ||
"sequence": null | ||
}, | ||
"default": { | ||
"Expression": [ | ||
"cuid", | ||
"String", | ||
[] | ||
] | ||
} | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "User", | ||
"name": "email", | ||
"type": { | ||
"Base": "String" | ||
}, | ||
"arity": "required", | ||
"isUnique": true | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "User", | ||
"name": "name", | ||
"type": { | ||
"Base": "String" | ||
}, | ||
"arity": "optional", | ||
"isUnique": false | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "User", | ||
"name": "posts", | ||
"type": { | ||
"Relation": { | ||
"to": "Post", | ||
"to_fields": [], | ||
"name": "PostToUser", | ||
"on_delete": "None" | ||
} | ||
}, | ||
"arity": "list", | ||
"isUnique": false | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "Post", | ||
"name": "id", | ||
"type": { | ||
"Base": "String" | ||
}, | ||
"arity": "required", | ||
"isUnique": true, | ||
"id": { | ||
"strategy": "Auto", | ||
"sequence": null | ||
}, | ||
"default": { | ||
"Expression": [ | ||
"cuid", | ||
"String", | ||
[] | ||
] | ||
} | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "Post", | ||
"name": "createdAt", | ||
"type": { | ||
"Base": "DateTime" | ||
}, | ||
"arity": "required", | ||
"isUnique": false, | ||
"default": { | ||
"Expression": [ | ||
"now", | ||
"DateTime", | ||
[] | ||
] | ||
} | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "Post", | ||
"name": "updatedAt", | ||
"type": { | ||
"Base": "DateTime" | ||
}, | ||
"arity": "required", | ||
"isUnique": false | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "Post", | ||
"name": "published", | ||
"type": { | ||
"Base": "Boolean" | ||
}, | ||
"arity": "required", | ||
"isUnique": false | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "Post", | ||
"name": "title", | ||
"type": { | ||
"Base": "String" | ||
}, | ||
"arity": "required", | ||
"isUnique": false | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "Post", | ||
"name": "content", | ||
"type": { | ||
"Base": "String" | ||
}, | ||
"arity": "optional", | ||
"isUnique": false | ||
}, | ||
{ | ||
"stepType": "CreateField", | ||
"model": "Post", | ||
"name": "author", | ||
"type": { | ||
"Relation": { | ||
"to": "User", | ||
"to_fields": [ | ||
"id" | ||
], | ||
"name": "PostToUser", | ||
"on_delete": "None" | ||
} | ||
}, | ||
"arity": "optional", | ||
"isUnique": false | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# IF THERE'S A GIT CONFLICT IN THIS FILE, DON'T SOLVE IT MANUALLY! | ||
# INSTEAD EXECUTE `prisma lift fix` | ||
# lift lockfile v1 | ||
# Read more about conflict resolution here: TODO | ||
|
||
20190618162719 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,5 @@ model Post { | |
published Boolean | ||
title String | ||
content String? | ||
author User | ||
author User? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters