Wiped out the DB to get the migration to work
This commit is contained in:
188
api/prisma/migrations/20201029214206-rejig-schema/README.md
Normal file
188
api/prisma/migrations/20201029214206-rejig-schema/README.md
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
# Migration `20201029214206-rejig-schema`
|
||||||
|
|
||||||
|
This migration has been generated by Kurt Hutten at 10/30/2020, 8:42:06 AM.
|
||||||
|
You can check out the [state of the schema](./schema.prisma) after the migration.
|
||||||
|
|
||||||
|
# explanation
|
||||||
|
|
||||||
|
The previous schema was really just thrown together to progress with parts of the client.
|
||||||
|
No relations had been included so this change in reality can be consider the initial schema.
|
||||||
|
|
||||||
|
## Database Steps
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE TABLE "PartReaction" (
|
||||||
|
"emote" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"partId" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
|
||||||
|
FOREIGN KEY ("userId") REFERENCES "User"("userName") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
FOREIGN KEY ("partId") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
)
|
||||||
|
|
||||||
|
CREATE TABLE "Comment" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"text" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
|
||||||
|
FOREIGN KEY ("id") REFERENCES "User"("userName") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
FOREIGN KEY ("id") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
PRIMARY KEY ("id")
|
||||||
|
)
|
||||||
|
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_Part" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"description" TEXT,
|
||||||
|
"code" TEXT,
|
||||||
|
"mainImage" TEXT,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"authorUserName" TEXT NOT NULL DEFAULT 'irevdev',
|
||||||
|
|
||||||
|
FOREIGN KEY ("authorUserName") REFERENCES "User"("userName") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
PRIMARY KEY ("title","authorUserName")
|
||||||
|
);
|
||||||
|
INSERT INTO "new_Part" ("id", "title", "description", "mainImage", "createdAt", "code") SELECT "id", "title", "description", "mainImage", "createdAt", "code" FROM "Part";
|
||||||
|
DROP TABLE "Part";
|
||||||
|
ALTER TABLE "new_Part" RENAME TO "Part";
|
||||||
|
CREATE UNIQUE INDEX "Part.id_unique" ON "Part"("id");
|
||||||
|
CREATE UNIQUE INDEX "Part.title_authorUserName_unique" ON "Part"("title", "authorUserName");
|
||||||
|
CREATE TABLE "new_User" (
|
||||||
|
"userName" TEXT NOT NULL DEFAULT 'irevdev',
|
||||||
|
"email" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
"image" TEXT,
|
||||||
|
"bio" TEXT,
|
||||||
|
PRIMARY KEY ("userName")
|
||||||
|
);
|
||||||
|
INSERT INTO "new_User" ("email", "createdAt", "updatedAt", "image", "bio") SELECT "email", "createdAt", "updatedAt", "image", "bio" FROM "User";
|
||||||
|
DROP TABLE "User";
|
||||||
|
ALTER TABLE "new_User" RENAME TO "User";
|
||||||
|
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
|
||||||
|
PRAGMA foreign_key_check;
|
||||||
|
PRAGMA foreign_keys=ON
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "PartReaction.emote_userId_partId_unique" ON "PartReaction"("emote", "userId", "partId")
|
||||||
|
|
||||||
|
PRAGMA foreign_keys=off;
|
||||||
|
DROP TABLE "Post";
|
||||||
|
PRAGMA foreign_keys=on
|
||||||
|
|
||||||
|
PRAGMA foreign_keys=off;
|
||||||
|
DROP TABLE "Contact";
|
||||||
|
PRAGMA foreign_keys=on
|
||||||
|
```
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
```diff
|
||||||
|
diff --git schema.prisma schema.prisma
|
||||||
|
migration 20201019072122-add-simplify-user-model..20201029214206-rejig-schema
|
||||||
|
--- datamodel.dml
|
||||||
|
+++ datamodel.dml
|
||||||
|
@@ -1,48 +1,76 @@
|
||||||
|
datasource DS {
|
||||||
|
provider = ["sqlite", "postgresql"]
|
||||||
|
- url = "***"
|
||||||
|
+ url = "***"
|
||||||
|
}
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
binaryTargets = "native"
|
||||||
|
}
|
||||||
|
-model Post {
|
||||||
|
- id Int @id @default(autoincrement())
|
||||||
|
- title String
|
||||||
|
- body String
|
||||||
|
+// sqlLight does not suport enums so we can't use enums until we set up postgresql in dev mode
|
||||||
|
+// enum Role {
|
||||||
|
+// USER
|
||||||
|
+// ADMIN
|
||||||
|
+// }
|
||||||
|
+
|
||||||
|
+// enum PartType {
|
||||||
|
+// CASCADESTUDIO
|
||||||
|
+// JSCAD
|
||||||
|
+// }
|
||||||
|
+
|
||||||
|
+model User {
|
||||||
|
+ userName String @id @default("irevdev")
|
||||||
|
+ email String @unique
|
||||||
|
+ // role should probably be a list [] and also use enums, neither are supported by sqllight, so we need to set up postgresql in dev
|
||||||
|
+ // maybe let netlify handle roles for now.
|
||||||
|
+ // role String @default("user")
|
||||||
|
+
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
+ updatedAt DateTime @updatedAt
|
||||||
|
+
|
||||||
|
+ image String? // url maybe id or file storage service? cloudinary?
|
||||||
|
+ bio String? //mark down
|
||||||
|
+ Part Part[]
|
||||||
|
+ Reaction PartReaction[]
|
||||||
|
+ Comment Comment[]
|
||||||
|
}
|
||||||
|
model Part {
|
||||||
|
- id Int @id @default(autoincrement())
|
||||||
|
- title String
|
||||||
|
- description String // markdown string
|
||||||
|
- code String @default("// Welcome to Cascade Studio! Here are some useful functions:\n// Translate(), Rotate(), Scale(), Union(), Difference(), Intersection()\n// Box(), Sphere(), Cylinder(), Cone(), Text3D(), Polygon()\n// Offset(), Extrude(), RotatedExtrude(), Revolve(), Pipe(), Loft(),\n// FilletEdges(), ChamferEdges(),\n// Slider(), Button(), Checkbox()\nlet holeRadius = Slider(\"Radius\", 30 , 20 , 40);\nlet sphere = Sphere(50);\nlet cylinderZ = Cylinder(holeRadius, 200, true);\nlet cylinderY = Rotate([0,1,0], 90, Cylinder(holeRadius, 200, true));\nlet cylinderX = Rotate([1,0,0], 90, Cylinder(holeRadius, 200, true));\nTranslate([0, 0, 50], Difference(sphere, [cylinderX, cylinderY, cylinderZ]));\n\nTranslate([-25, 0, 40], Text3D(\"Hi!\"));\n// Don't forget to push imported or oc-defined shapes into sceneShapes to add them to the workspace!")
|
||||||
|
- mainImage String // link to cloudinary
|
||||||
|
- createdAt DateTime @default(now())
|
||||||
|
- // userId
|
||||||
|
- //likes, comments, reactions
|
||||||
|
+ id String @unique @default(uuid())
|
||||||
|
+ title String
|
||||||
|
+ description String? // markdown string
|
||||||
|
+ code String?
|
||||||
|
+ mainImage String? // link to cloudinary
|
||||||
|
+ createdAt DateTime @default(now())
|
||||||
|
+ updatedAt DateTime @default(now()) @updatedAt
|
||||||
|
+ author User @relation(fields: [authorUserName], references: [userName])
|
||||||
|
+ authorUserName String @default("irevdev")
|
||||||
|
+
|
||||||
|
+ Comment Comment[]
|
||||||
|
+ Reaction PartReaction[]
|
||||||
|
+ @@id([title, authorUserName])
|
||||||
|
+ @@unique([title, authorUserName])
|
||||||
|
}
|
||||||
|
-model Contact {
|
||||||
|
- id Int @id @default(autoincrement())
|
||||||
|
- name String
|
||||||
|
- email String
|
||||||
|
- message String
|
||||||
|
+model PartReaction {
|
||||||
|
+ emote String // an emoji
|
||||||
|
+ userId String
|
||||||
|
+ user User @relation(fields: [userId], references: [userName])
|
||||||
|
+ partId String
|
||||||
|
+ part Part @relation(fields: [partId], references: [id])
|
||||||
|
+
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
+ updatedAt DateTime @updatedAt
|
||||||
|
+ @@unique([emote, userId, partId])
|
||||||
|
}
|
||||||
|
-model User {
|
||||||
|
- id Int @id @default(autoincrement())
|
||||||
|
- email String @unique
|
||||||
|
- // userName String @unique
|
||||||
|
- // issuer String @unique
|
||||||
|
+model Comment {
|
||||||
|
+ id String @id @default(uuid())
|
||||||
|
+ text String // the comment, should I allow mark down?
|
||||||
|
+ user User @relation(fields: [id], references: [userName])
|
||||||
|
+ part Part @relation(fields: [id], references: [id])
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
-
|
||||||
|
- image String? // url maybe id or file storage service? cloudinary?
|
||||||
|
- bio String? //mark down
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
datasource DS {
|
||||||
|
provider = ["sqlite", "postgresql"]
|
||||||
|
url = "***"
|
||||||
|
}
|
||||||
|
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
binaryTargets = "native"
|
||||||
|
}
|
||||||
|
|
||||||
|
// sqlLight does not suport enums so we can't use enums until we set up postgresql in dev mode
|
||||||
|
// enum Role {
|
||||||
|
// USER
|
||||||
|
// ADMIN
|
||||||
|
// }
|
||||||
|
|
||||||
|
// enum PartType {
|
||||||
|
// CASCADESTUDIO
|
||||||
|
// JSCAD
|
||||||
|
// }
|
||||||
|
|
||||||
|
model User {
|
||||||
|
userName String @id @default(uuid())
|
||||||
|
email String @unique
|
||||||
|
// role should probably be a list [] and also use enums, neither are supported by sqllight, so we need to set up postgresql in dev
|
||||||
|
// maybe let netlify handle roles for now.
|
||||||
|
// role String @default("user")
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
image String? // url maybe id or file storage service? cloudinary?
|
||||||
|
bio String? //mark down
|
||||||
|
Part Part[]
|
||||||
|
Reaction PartReaction[]
|
||||||
|
Comment Comment[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Part {
|
||||||
|
id String @unique @default(uuid())
|
||||||
|
title String
|
||||||
|
description String? // markdown string
|
||||||
|
code String?
|
||||||
|
mainImage String? // link to cloudinary
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
author User @relation(fields: [authorUserName], references: [userName])
|
||||||
|
authorUserName String
|
||||||
|
|
||||||
|
Comment Comment[]
|
||||||
|
Reaction PartReaction[]
|
||||||
|
@@id([title, authorUserName])
|
||||||
|
@@unique([title, authorUserName])
|
||||||
|
}
|
||||||
|
|
||||||
|
model PartReaction {
|
||||||
|
emote String // an emoji
|
||||||
|
userId String
|
||||||
|
user User @relation(fields: [userId], references: [userName])
|
||||||
|
partId String
|
||||||
|
part Part @relation(fields: [partId], references: [id])
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
@@unique([emote, userId, partId])
|
||||||
|
}
|
||||||
|
|
||||||
|
model Comment {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
text String // the comment, should I allow mark down?
|
||||||
|
user User @relation(fields: [id], references: [userName])
|
||||||
|
part Part @relation(fields: [id], references: [id])
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
706
api/prisma/migrations/20201029214206-rejig-schema/steps.json
Normal file
706
api/prisma/migrations/20201029214206-rejig-schema/steps.json
Normal file
@@ -0,0 +1,706 @@
|
|||||||
|
{
|
||||||
|
"version": "0.3.14-fixed",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"tag": "CreateModel",
|
||||||
|
"model": "PartReaction"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "emote",
|
||||||
|
"type": "String",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "userId",
|
||||||
|
"type": "String",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "user",
|
||||||
|
"type": "User",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "user"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "user"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "fields",
|
||||||
|
"value": "[userId]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "user"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "references",
|
||||||
|
"value": "[userName]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "partId",
|
||||||
|
"type": "String",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "part",
|
||||||
|
"type": "Part",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "part"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "part"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "fields",
|
||||||
|
"value": "[partId]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "part"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "references",
|
||||||
|
"value": "[id]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "createdAt",
|
||||||
|
"type": "DateTime",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "createdAt"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "createdAt"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"value": "now()"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "updatedAt",
|
||||||
|
"type": "DateTime",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"field": "updatedAt"
|
||||||
|
},
|
||||||
|
"directive": "updatedAt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Model",
|
||||||
|
"model": "PartReaction",
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"value": "[emote, userId, partId]"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"directive": "unique"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateModel",
|
||||||
|
"model": "Comment"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "id",
|
||||||
|
"type": "String",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "id"
|
||||||
|
},
|
||||||
|
"directive": "id"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "id"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "id"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"value": "uuid()"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "text",
|
||||||
|
"type": "String",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "user",
|
||||||
|
"type": "User",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "user"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "user"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "fields",
|
||||||
|
"value": "[id]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "user"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "references",
|
||||||
|
"value": "[userName]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "part",
|
||||||
|
"type": "Part",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "part"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "part"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "fields",
|
||||||
|
"value": "[id]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "part"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "references",
|
||||||
|
"value": "[id]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "createdAt",
|
||||||
|
"type": "DateTime",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "createdAt"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "createdAt"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"value": "now()"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "updatedAt",
|
||||||
|
"type": "DateTime",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Comment",
|
||||||
|
"field": "updatedAt"
|
||||||
|
},
|
||||||
|
"directive": "updatedAt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "DeleteModel",
|
||||||
|
"model": "Post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "DeleteModel",
|
||||||
|
"model": "Contact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "updatedAt",
|
||||||
|
"type": "DateTime",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "updatedAt"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "updatedAt"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"value": "now()"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "updatedAt"
|
||||||
|
},
|
||||||
|
"directive": "updatedAt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "author",
|
||||||
|
"type": "User",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "author"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "author"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "fields",
|
||||||
|
"value": "[authorUserName]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "author"
|
||||||
|
},
|
||||||
|
"directive": "relation"
|
||||||
|
},
|
||||||
|
"argument": "references",
|
||||||
|
"value": "[userName]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "authorUserName",
|
||||||
|
"type": "String",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "authorUserName"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "authorUserName"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"value": "\"irevdev\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "Comment",
|
||||||
|
"type": "Comment",
|
||||||
|
"arity": "List"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "Reaction",
|
||||||
|
"type": "PartReaction",
|
||||||
|
"arity": "List"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "UpdateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "id",
|
||||||
|
"type": "String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "id"
|
||||||
|
},
|
||||||
|
"directive": "unique"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "UpdateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "id"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"newValue": "uuid()"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "DeleteDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "id"
|
||||||
|
},
|
||||||
|
"directive": "id"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "UpdateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "description",
|
||||||
|
"arity": "Optional"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "UpdateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "mainImage",
|
||||||
|
"arity": "Optional"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "UpdateField",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "code",
|
||||||
|
"arity": "Optional"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "DeleteDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "code"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Model",
|
||||||
|
"model": "Part"
|
||||||
|
},
|
||||||
|
"directive": "id"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Model",
|
||||||
|
"model": "Part"
|
||||||
|
},
|
||||||
|
"directive": "id"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"value": "[title, authorUserName]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Model",
|
||||||
|
"model": "Part",
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"value": "[title, authorUserName]"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"directive": "unique"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "User",
|
||||||
|
"field": "userName",
|
||||||
|
"type": "String",
|
||||||
|
"arity": "Required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "User",
|
||||||
|
"field": "userName"
|
||||||
|
},
|
||||||
|
"directive": "id"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "User",
|
||||||
|
"field": "userName"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateArgument",
|
||||||
|
"location": {
|
||||||
|
"tag": "Directive",
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "User",
|
||||||
|
"field": "userName"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
},
|
||||||
|
"argument": "",
|
||||||
|
"value": "\"irevdev\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "User",
|
||||||
|
"field": "Part",
|
||||||
|
"type": "Part",
|
||||||
|
"arity": "List"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "User",
|
||||||
|
"field": "Reaction",
|
||||||
|
"type": "PartReaction",
|
||||||
|
"arity": "List"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "CreateField",
|
||||||
|
"model": "User",
|
||||||
|
"field": "Comment",
|
||||||
|
"type": "Comment",
|
||||||
|
"arity": "List"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "DeleteField",
|
||||||
|
"model": "User",
|
||||||
|
"field": "id"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
91
api/prisma/migrations/20201030061957-rejig-schema/README.md
Normal file
91
api/prisma/migrations/20201030061957-rejig-schema/README.md
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
# Migration `20201030061957-rejig-schema`
|
||||||
|
|
||||||
|
This migration has been generated by Kurt Hutten at 10/30/2020, 5:19:57 PM.
|
||||||
|
You can check out the [state of the schema](./schema.prisma) after the migration.
|
||||||
|
|
||||||
|
## Database Steps
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE TABLE "User" (
|
||||||
|
"userName" TEXT NOT NULL,
|
||||||
|
"email" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
"image" TEXT,
|
||||||
|
"bio" TEXT,
|
||||||
|
PRIMARY KEY ("userName")
|
||||||
|
)
|
||||||
|
|
||||||
|
CREATE TABLE "Part" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"description" TEXT,
|
||||||
|
"code" TEXT,
|
||||||
|
"mainImage" TEXT,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
"authorUserName" TEXT NOT NULL,
|
||||||
|
|
||||||
|
FOREIGN KEY ("authorUserName") REFERENCES "User"("userName") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
PRIMARY KEY ("title","authorUserName")
|
||||||
|
)
|
||||||
|
|
||||||
|
CREATE TABLE "PartReaction" (
|
||||||
|
"emote" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"partId" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
|
||||||
|
FOREIGN KEY ("userId") REFERENCES "User"("userName") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
FOREIGN KEY ("partId") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
)
|
||||||
|
|
||||||
|
CREATE TABLE "Comment" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"text" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
|
||||||
|
FOREIGN KEY ("id") REFERENCES "User"("userName") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
FOREIGN KEY ("id") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
PRIMARY KEY ("id")
|
||||||
|
)
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email")
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "Part.id_unique" ON "Part"("id")
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "Part.title_authorUserName_unique" ON "Part"("title", "authorUserName")
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "PartReaction.emote_userId_partId_unique" ON "PartReaction"("emote", "userId", "partId")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
```diff
|
||||||
|
diff --git schema.prisma schema.prisma
|
||||||
|
migration 20201029214206-rejig-schema..20201030061957-rejig-schema
|
||||||
|
--- datamodel.dml
|
||||||
|
+++ datamodel.dml
|
||||||
|
@@ -1,7 +1,7 @@
|
||||||
|
datasource DS {
|
||||||
|
provider = ["sqlite", "postgresql"]
|
||||||
|
- url = "***"
|
||||||
|
+ url = "***"
|
||||||
|
}
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
@@ -19,9 +19,9 @@
|
||||||
|
// JSCAD
|
||||||
|
// }
|
||||||
|
model User {
|
||||||
|
- userName String @id @default(uuid())
|
||||||
|
+ userName String @id
|
||||||
|
email String @unique
|
||||||
|
// role should probably be a list [] and also use enums, neither are supported by sqllight, so we need to set up postgresql in dev
|
||||||
|
// maybe let netlify handle roles for now.
|
||||||
|
// role String @default("user")
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
datasource DS {
|
||||||
|
provider = ["sqlite", "postgresql"]
|
||||||
|
url = "***"
|
||||||
|
}
|
||||||
|
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
binaryTargets = "native"
|
||||||
|
}
|
||||||
|
|
||||||
|
// sqlLight does not suport enums so we can't use enums until we set up postgresql in dev mode
|
||||||
|
// enum Role {
|
||||||
|
// USER
|
||||||
|
// ADMIN
|
||||||
|
// }
|
||||||
|
|
||||||
|
// enum PartType {
|
||||||
|
// CASCADESTUDIO
|
||||||
|
// JSCAD
|
||||||
|
// }
|
||||||
|
|
||||||
|
model User {
|
||||||
|
userName String @id
|
||||||
|
email String @unique
|
||||||
|
// role should probably be a list [] and also use enums, neither are supported by sqllight, so we need to set up postgresql in dev
|
||||||
|
// maybe let netlify handle roles for now.
|
||||||
|
// role String @default("user")
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
image String? // url maybe id or file storage service? cloudinary?
|
||||||
|
bio String? //mark down
|
||||||
|
Part Part[]
|
||||||
|
Reaction PartReaction[]
|
||||||
|
Comment Comment[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Part {
|
||||||
|
id String @unique @default(uuid())
|
||||||
|
title String
|
||||||
|
description String? // markdown string
|
||||||
|
code String?
|
||||||
|
mainImage String? // link to cloudinary
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
author User @relation(fields: [authorUserName], references: [userName])
|
||||||
|
authorUserName String
|
||||||
|
|
||||||
|
Comment Comment[]
|
||||||
|
Reaction PartReaction[]
|
||||||
|
@@id([title, authorUserName])
|
||||||
|
@@unique([title, authorUserName])
|
||||||
|
}
|
||||||
|
|
||||||
|
model PartReaction {
|
||||||
|
emote String // an emoji
|
||||||
|
userId String
|
||||||
|
user User @relation(fields: [userId], references: [userName])
|
||||||
|
partId String
|
||||||
|
part Part @relation(fields: [partId], references: [id])
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
@@unique([emote, userId, partId])
|
||||||
|
}
|
||||||
|
|
||||||
|
model Comment {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
text String // the comment, should I allow mark down?
|
||||||
|
user User @relation(fields: [id], references: [userName])
|
||||||
|
part Part @relation(fields: [id], references: [id])
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
38
api/prisma/migrations/20201030061957-rejig-schema/steps.json
Normal file
38
api/prisma/migrations/20201030061957-rejig-schema/steps.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"version": "0.3.14-fixed",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"tag": "DeleteDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "updatedAt"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "DeleteDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "Part",
|
||||||
|
"field": "authorUserName"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "DeleteDirective",
|
||||||
|
"location": {
|
||||||
|
"path": {
|
||||||
|
"tag": "Field",
|
||||||
|
"model": "User",
|
||||||
|
"field": "userName"
|
||||||
|
},
|
||||||
|
"directive": "default"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -6,4 +6,6 @@
|
|||||||
20201011082558-add-code-not-needed-upon-create
|
20201011082558-add-code-not-needed-upon-create
|
||||||
20201011095227-create-contact
|
20201011095227-create-contact
|
||||||
20201018233330-add-simple-user-model
|
20201018233330-add-simple-user-model
|
||||||
20201019072122-add-simplify-user-model
|
20201019072122-add-simplify-user-model
|
||||||
|
20201029214206-rejig-schema
|
||||||
|
20201030061957-rejig-schema
|
||||||
@@ -8,41 +8,69 @@ generator client {
|
|||||||
binaryTargets = "native"
|
binaryTargets = "native"
|
||||||
}
|
}
|
||||||
|
|
||||||
model Post {
|
// sqlLight does not suport enums so we can't use enums until we set up postgresql in dev mode
|
||||||
id Int @id @default(autoincrement())
|
// enum Role {
|
||||||
title String
|
// USER
|
||||||
body String
|
// ADMIN
|
||||||
createdAt DateTime @default(now())
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
model Part {
|
// enum PartType {
|
||||||
id Int @id @default(autoincrement())
|
// CASCADESTUDIO
|
||||||
title String
|
// JSCAD
|
||||||
description String // markdown string
|
// }
|
||||||
code String @default("// Welcome to Cascade Studio! Here are some useful functions:\n// Translate(), Rotate(), Scale(), Union(), Difference(), Intersection()\n// Box(), Sphere(), Cylinder(), Cone(), Text3D(), Polygon()\n// Offset(), Extrude(), RotatedExtrude(), Revolve(), Pipe(), Loft(),\n// FilletEdges(), ChamferEdges(),\n// Slider(), Button(), Checkbox()\nlet holeRadius = Slider(\"Radius\", 30 , 20 , 40);\nlet sphere = Sphere(50);\nlet cylinderZ = Cylinder(holeRadius, 200, true);\nlet cylinderY = Rotate([0,1,0], 90, Cylinder(holeRadius, 200, true));\nlet cylinderX = Rotate([1,0,0], 90, Cylinder(holeRadius, 200, true));\nTranslate([0, 0, 50], Difference(sphere, [cylinderX, cylinderY, cylinderZ]));\n\nTranslate([-25, 0, 40], Text3D(\"Hi!\"));\n// Don't forget to push imported or oc-defined shapes into sceneShapes to add them to the workspace!")
|
|
||||||
mainImage String // link to cloudinary
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
// userId
|
|
||||||
//likes, comments, reactions
|
|
||||||
}
|
|
||||||
|
|
||||||
model Contact {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
name String
|
|
||||||
email String
|
|
||||||
message String
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
}
|
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id Int @id @default(autoincrement())
|
userName String @id
|
||||||
email String @unique
|
email String @unique
|
||||||
// userName String @unique
|
// role should probably be a list [] and also use enums, neither are supported by sqllight, so we need to set up postgresql in dev
|
||||||
// issuer String @unique
|
// maybe let netlify handle roles for now.
|
||||||
|
// role String @default("user")
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
image String? // url maybe id or file storage service? cloudinary?
|
image String? // url maybe id or file storage service? cloudinary?
|
||||||
bio String? //mark down
|
bio String? //mark down
|
||||||
|
Part Part[]
|
||||||
|
Reaction PartReaction[]
|
||||||
|
Comment Comment[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Part {
|
||||||
|
id String @unique @default(uuid())
|
||||||
|
title String
|
||||||
|
description String? // markdown string
|
||||||
|
code String?
|
||||||
|
mainImage String? // link to cloudinary
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
author User @relation(fields: [authorUserName], references: [userName])
|
||||||
|
authorUserName String
|
||||||
|
|
||||||
|
Comment Comment[]
|
||||||
|
Reaction PartReaction[]
|
||||||
|
@@id([title, authorUserName])
|
||||||
|
@@unique([title, authorUserName])
|
||||||
|
}
|
||||||
|
|
||||||
|
model PartReaction {
|
||||||
|
emote String // an emoji
|
||||||
|
userId String
|
||||||
|
user User @relation(fields: [userId], references: [userName])
|
||||||
|
partId String
|
||||||
|
part Part @relation(fields: [partId], references: [id])
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
@@unique([emote, userId, partId])
|
||||||
|
}
|
||||||
|
|
||||||
|
model Comment {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
text String // the comment, should I allow mark down?
|
||||||
|
user User @relation(fields: [id], references: [userName])
|
||||||
|
part Part @relation(fields: [id], references: [id])
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user