Tags are working again!

This commit is contained in:
Martin Sosic 2020-11-27 14:25:47 +01:00
parent 57412b8b3c
commit cdb7484279
32 changed files with 781 additions and 1521 deletions

View File

@ -19,6 +19,7 @@ Todo:
- [x] Add tags to articles. - [x] Add tags to articles.
- [x] Show Popular Tags on home page. - [x] Show Popular Tags on home page.
- [x] Favorite articles. - [x] Favorite articles.
- [ ] Make tags work again (Prisma problems!).
- [ ] Following other users. - [ ] Following other users.
- [ ] Paginated lists of articles (on profile page, on home page). - [ ] Paginated lists of articles (on profile page, on home page).
- [ ] Use Bootstrap 4 styling. - [ ] Use Bootstrap 4 styling.

View File

@ -33,7 +33,7 @@ const articleInclude = {
// It would be cool if we had some protection against making this mistake easily. // It would be cool if we had some protection against making this mistake easily.
select: userPublicSelection select: userPublicSelection
}, },
//tags: true, // TODO: This causes prisma to explode, uncomment once I get it working. tags: true,
favoritedBy: { favoritedBy: {
select: { select: {
// TODO: Tricky, if I forgot this select here, sensitive data could leak out (hashed password). // TODO: Tricky, if I forgot this select here, sensitive data could leak out (hashed password).
@ -57,7 +57,6 @@ const getArticles = async ({ where }, context) => {
for (const article of articles) { for (const article of articles) {
articleSetFavoritedFields(article, context.user) articleSetFavoritedFields(article, context.user)
article.tags = [] // TODO: Remove this, it is just temporary fix until we fix problem with including tags.
} }
return articles return articles
@ -81,7 +80,6 @@ export const getArticle = async ({ slug }, context) => {
include: articleInclude include: articleInclude
}) })
articleSetFavoritedFields(article, context.user) articleSetFavoritedFields(article, context.user)
article.tags = [] // TODO: Remove this, it is just temporary fix until we fix problem with including tags.
return article return article
} }

View File

@ -1,43 +0,0 @@
# Migration `20201030161549-user`
This migration has been generated by Martin Sosic at 10/30/2020, 5:15:49 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"description" TEXT NOT NULL,
"isDone" BOOLEAN NOT NULL DEFAULT false
)
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration ..20201030161549-user
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,17 @@
+
+datasource db {
+ provider = "sqlite"
+ url = "***"
+}
+
+generator client {
+ provider = "prisma-client-js"
+ output = "../server/node_modules/.prisma/client"
+}
+
+model User {
+ id Int @id @default(autoincrement())
+ description String
+ isDone Boolean @default(false)
+}
+
```

View File

@ -1,17 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)
}

View File

@ -1,113 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateSource",
"source": "db"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Source",
"source": "db"
},
"argument": "provider",
"value": "\"sqlite\""
},
{
"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": "description",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "User",
"field": "isDone",
"type": "Boolean",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "isDone"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "User",
"field": "isDone"
},
"directive": "default"
},
"argument": "",
"value": "false"
}
]
}

View File

@ -1,52 +0,0 @@
# Migration `20201030185724-fixed-user`
This migration has been generated by Martin Sosic at 10/30/2020, 7:57:24 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL
);
INSERT INTO "new_User" ("id") SELECT "id" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User.username_unique" ON "User"("username");
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201030161549-user..20201030185724-fixed-user
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -10,8 +10,9 @@
}
model User {
id Int @id @default(autoincrement())
- description String
- isDone Boolean @default(false)
+ username String @unique
+ email String @unique
+ password String
}
```

View File

@ -1,18 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
}

View File

@ -1,58 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "User",
"field": "username",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "username"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "User",
"field": "email",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "email"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "User",
"field": "password",
"type": "String",
"arity": "Required"
},
{
"tag": "DeleteField",
"model": "User",
"field": "description"
},
{
"tag": "DeleteField",
"model": "User",
"field": "isDone"
}
]
}

View File

@ -1,38 +0,0 @@
# Migration `20201117145436-added-bio-and-picture-to-user`
This migration has been generated by Martin Sosic at 11/17/2020, 3:54:36 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
ALTER TABLE "User" ADD COLUMN "bio" TEXT;
ALTER TABLE "User" ADD COLUMN "profilePictureUrl" TEXT
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201030185724-fixed-user..20201117145436-added-bio-and-picture-to-user
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -13,6 +13,8 @@
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
+ bio String?
+ profilePictureUrl String?
}
```

View File

@ -1,20 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
}

View File

@ -1,19 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "User",
"field": "bio",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "User",
"field": "profilePictureUrl",
"type": "String",
"arity": "Optional"
}
]
}

View File

@ -1,53 +0,0 @@
# Migration `20201119144622-added-article-entity`
This migration has been generated by Martin Sosic at 11/19/2020, 3:46:22 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "Article" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
"markdownContent" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201117145436-added-bio-and-picture-to-user..20201119144622-added-article-entity
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -15,6 +15,16 @@
email String @unique
password String
bio String?
profilePictureUrl String?
+ articles Article[]
}
+model Article {
+ id Int @id @default(autoincrement())
+ title String
+ description String
+ markdownContent String
+ user User @relation(fields: [userId], references: [id])
+ userId Int
+}
+
```

View File

@ -1,30 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
articles Article[]
}
model Article {
id Int @id @default(autoincrement())
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
userId Int
}

View File

@ -1,133 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateModel",
"model": "Article"
},
{
"tag": "CreateField",
"model": "Article",
"field": "id",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "id"
},
"directive": "id"
}
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "id"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "id"
},
"directive": "default"
},
"argument": "",
"value": "autoincrement()"
},
{
"tag": "CreateField",
"model": "Article",
"field": "title",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Article",
"field": "description",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Article",
"field": "markdownContent",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Article",
"field": "user",
"type": "User",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "user"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "user"
},
"directive": "relation"
},
"argument": "fields",
"value": "[userId]"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "user"
},
"directive": "relation"
},
"argument": "references",
"value": "[id]"
},
{
"tag": "CreateField",
"model": "Article",
"field": "userId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "User",
"field": "articles",
"type": "Article",
"arity": "List"
}
]
}

View File

@ -1,62 +0,0 @@
# Migration `20201124192901-added-created-at-to-article`
This migration has been generated by Martin Sosic at 11/24/2020, 8:29:01 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Article" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
"markdownContent" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Article" ("id", "title", "description", "markdownContent", "userId") SELECT "id", "title", "description", "markdownContent", "userId" FROM "Article";
DROP TABLE "Article";
ALTER TABLE "new_Article" RENAME TO "Article";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201119144622-added-article-entity..20201124192901-added-created-at-to-article
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -19,12 +19,13 @@
articles Article[]
}
model Article {
- id Int @id @default(autoincrement())
- title String
- description String
- markdownContent String
- user User @relation(fields: [userId], references: [id])
- userId Int
+ id Int @id @default(autoincrement())
+ createdAt DateTime @default(now())
+ title String
+ description String
+ markdownContent String
+ user User @relation(fields: [userId], references: [id])
+ userId Int
}
```

View File

@ -1,31 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
articles Article[]
}
model Article {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
userId Int
}

View File

@ -1,37 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "Article",
"field": "createdAt",
"type": "DateTime",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "createdAt"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "createdAt"
},
"directive": "default"
},
"argument": "",
"value": "now()"
}
]
}

View File

@ -1,66 +0,0 @@
# Migration `20201124195623-added-slug-to-article`
This migration has been generated by Martin Sosic at 11/24/2020, 8:56:23 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"bio" TEXT,
"profilePictureUrl" TEXT
)
CREATE TABLE "Article" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"slug" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
"markdownContent" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE UNIQUE INDEX "User.username_unique" ON "User"("username")
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email")
CREATE UNIQUE INDEX "Article.slug_unique" ON "Article"("slug")
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201124192901-added-created-at-to-article..20201124195623-added-slug-to-article
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -20,9 +20,11 @@
}
model Article {
id Int @id @default(autoincrement())
+ slug String @unique
createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
```

View File

@ -1,33 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
articles Article[]
}
model Article {
id Int @id @default(autoincrement())
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
userId Int
}

View File

@ -1,41 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "Article",
"field": "slug",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "slug"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "Article",
"field": "updatedAt",
"type": "DateTime",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "updatedAt"
},
"directive": "updatedAt"
}
}
]
}

View File

@ -1,85 +0,0 @@
# Migration `20201124212222-added-comment`
This migration has been generated by Martin Sosic at 11/24/2020, 10:22:22 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "Comment" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"content" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
"articleId" INTEGER NOT NULL,
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE
)
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201124195623-added-slug-to-article..20201124212222-added-comment
--- datamodel.dml
+++ datamodel.dml
@@ -1,33 +1,52 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
- id Int @id @default(autoincrement())
- username String @unique
- email String @unique
- password String
- bio String?
+ id Int @id @default(autoincrement())
+ username String @unique
+ email String @unique
+ password String
+ bio String?
profilePictureUrl String?
- articles Article[]
+
+ articles Article[]
+ comments Comment[]
}
model Article {
id Int @id @default(autoincrement())
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
+
title String
description String
markdownContent String
+
user User @relation(fields: [userId], references: [id])
userId Int
+
+ comments Comment[]
}
+model Comment {
+ id Int @id @default(autoincrement())
+ createdAt DateTime @default(now())
+
+ content String
+
+ user User @relation(fields: [userId], references: [id])
+ userId Int
+
+ article Article @relation(fields: [articleId], references: [id])
+ articleId Int
+}
+
```

View File

@ -1,52 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
articles Article[]
comments Comment[]
}
model Article {
id Int @id @default(autoincrement())
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
userId Int
comments Comment[]
}
model Comment {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
content String
user User @relation(fields: [userId], references: [id])
userId Int
article Article @relation(fields: [articleId], references: [id])
articleId Int
}

View File

@ -1,211 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateModel",
"model": "Comment"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "id",
"type": "Int",
"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": "autoincrement()"
},
{
"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": "content",
"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": "[userId]"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Comment",
"field": "user"
},
"directive": "relation"
},
"argument": "references",
"value": "[id]"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "userId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "article",
"type": "Article",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Comment",
"field": "article"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Comment",
"field": "article"
},
"directive": "relation"
},
"argument": "fields",
"value": "[articleId]"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Comment",
"field": "article"
},
"directive": "relation"
},
"argument": "references",
"value": "[id]"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "articleId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "User",
"field": "comments",
"type": "Comment",
"arity": "List"
},
{
"tag": "CreateField",
"model": "Article",
"field": "comments",
"type": "Comment",
"arity": "List"
}
]
}

View File

@ -1,76 +0,0 @@
# Migration `20201125134317-added-article-tag`
This migration has been generated by Martin Sosic at 11/25/2020, 2:43:17 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "ArticleTag" (
"name" TEXT NOT NULL,
PRIMARY KEY ("name")
)
CREATE TABLE "_ArticleToArticleTag" (
"A" INTEGER NOT NULL,
"B" TEXT NOT NULL,
FOREIGN KEY ("A") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("B") REFERENCES "ArticleTag"("name") ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE UNIQUE INDEX "_ArticleToArticleTag_AB_unique" ON "_ArticleToArticleTag"("A", "B")
CREATE INDEX "_ArticleToArticleTag_B_index" ON "_ArticleToArticleTag"("B")
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201124212222-added-comment..20201125134317-added-article-tag
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -25,28 +25,31 @@
id Int @id @default(autoincrement())
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
-
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
userId Int
-
comments Comment[]
+ tags ArticleTag[]
}
model Comment {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
-
content String
user User @relation(fields: [userId], references: [id])
userId Int
-
article Article @relation(fields: [articleId], references: [id])
articleId Int
}
+model ArticleTag {
+ name String @id
+
+ articles Article[]
+}
+
```

View File

@ -1,55 +0,0 @@
datasource db {
provider = "sqlite"
url = "***"
}
generator client {
provider = "prisma-client-js"
output = "../server/node_modules/.prisma/client"
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
articles Article[]
comments Comment[]
}
model Article {
id Int @id @default(autoincrement())
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
userId Int
comments Comment[]
tags ArticleTag[]
}
model Comment {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
content String
user User @relation(fields: [userId], references: [id])
userId Int
article Article @relation(fields: [articleId], references: [id])
articleId Int
}
model ArticleTag {
name String @id
articles Article[]
}

View File

@ -1,41 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateModel",
"model": "ArticleTag"
},
{
"tag": "CreateField",
"model": "ArticleTag",
"field": "name",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "ArticleTag",
"field": "name"
},
"directive": "id"
}
},
{
"tag": "CreateField",
"model": "ArticleTag",
"field": "articles",
"type": "Article",
"arity": "List"
},
{
"tag": "CreateField",
"model": "Article",
"field": "tags",
"type": "ArticleTag",
"arity": "List"
}
]
}

View File

@ -1,56 +0,0 @@
# Migration `20201126162628-added-favorite-articles`
This migration has been generated by Martin Sosic at 11/26/2020, 5:26:28 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "_FavoritedArticles" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL,
FOREIGN KEY ("A") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE UNIQUE INDEX "_FavoritedArticles_AB_unique" ON "_FavoritedArticles"("A", "B")
CREATE INDEX "_FavoritedArticles_B_index" ON "_FavoritedArticles"("B")
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201125134317-added-article-tag..20201126162628-added-favorite-articles
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "sqlite"
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -18,8 +18,9 @@
profilePictureUrl String?
articles Article[]
comments Comment[]
+ favoriteArticles Article[] @relation("FavoritedArticles")
}
model Article {
id Int @id @default(autoincrement())
@@ -33,8 +34,9 @@
user User @relation(fields: [userId], references: [id])
userId Int
comments Comment[]
tags ArticleTag[]
+ favoritedBy User[] @relation("FavoritedArticles")
}
model Comment {
id Int @id @default(autoincrement())
```

View File

@ -1,69 +0,0 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "User",
"field": "favoriteArticles",
"type": "Article",
"arity": "List"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "favoriteArticles"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "User",
"field": "favoriteArticles"
},
"directive": "relation"
},
"argument": "",
"value": "\"FavoritedArticles\""
},
{
"tag": "CreateField",
"model": "Article",
"field": "favoritedBy",
"type": "User",
"arity": "List"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "favoritedBy"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "favoritedBy"
},
"directive": "relation"
},
"argument": "",
"value": "\"FavoritedArticles\""
}
]
}

View File

@ -0,0 +1,145 @@
# Migration `20201127131647-init`
This migration has been generated by Martin Sosic at 11/27/2020, 2:16:47 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"bio" TEXT,
"profilePictureUrl" TEXT
)
CREATE TABLE "Article" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"slug" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
"markdownContent" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE TABLE "Comment" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"content" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
"articleId" INTEGER NOT NULL,
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE TABLE "ArticleTag" (
"name" TEXT NOT NULL,
PRIMARY KEY ("name")
)
CREATE TABLE "_FavoritedArticles" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL,
FOREIGN KEY ("A") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE TABLE "_ArticleToArticleTag" (
"A" INTEGER NOT NULL,
"B" TEXT NOT NULL,
FOREIGN KEY ("A") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("B") REFERENCES "ArticleTag"("name") ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE UNIQUE INDEX "User.username_unique" ON "User"("username")
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email")
CREATE UNIQUE INDEX "Article.slug_unique" ON "Article"("slug")
CREATE UNIQUE INDEX "_FavoritedArticles_AB_unique" ON "_FavoritedArticles"("A", "B")
CREATE INDEX "_FavoritedArticles_B_index" ON "_FavoritedArticles"("B")
CREATE UNIQUE INDEX "_ArticleToArticleTag_AB_unique" ON "_ArticleToArticleTag"("A", "B")
CREATE INDEX "_ArticleToArticleTag_B_index" ON "_ArticleToArticleTag"("B")
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration ..20201127131647-init
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,57 @@
+
+datasource db {
+ provider = "sqlite"
+ url = "***"
+}
+
+generator client {
+ provider = "prisma-client-js"
+ output = "../server/node_modules/.prisma/client"
+}
+
+model User {
+ id Int @id @default(autoincrement())
+ username String @unique
+ email String @unique
+ password String
+ bio String?
+ profilePictureUrl String?
+
+ articles Article[]
+ comments Comment[]
+ favoriteArticles Article[] @relation("FavoritedArticles")
+}
+
+model Article {
+ id Int @id @default(autoincrement())
+ slug String @unique
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ title String
+ description String
+ markdownContent String
+
+ user User @relation(fields: [userId], references: [id])
+ userId Int
+ comments Comment[]
+ tags ArticleTag[]
+ favoritedBy User[] @relation("FavoritedArticles")
+}
+
+model Comment {
+ id Int @id @default(autoincrement())
+ createdAt DateTime @default(now())
+ content String
+
+ user User @relation(fields: [userId], references: [id])
+ userId Int
+ article Article @relation(fields: [articleId], references: [id])
+ articleId Int
+}
+
+model ArticleTag {
+ name String @id
+
+ articles Article[]
+}
+
```

View File

@ -0,0 +1,633 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateSource",
"source": "db"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Source",
"source": "db"
},
"argument": "provider",
"value": "\"sqlite\""
},
{
"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": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "username"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "User",
"field": "email",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "email"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "User",
"field": "password",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "User",
"field": "bio",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "User",
"field": "profilePictureUrl",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "User",
"field": "articles",
"type": "Article",
"arity": "List"
},
{
"tag": "CreateField",
"model": "User",
"field": "comments",
"type": "Comment",
"arity": "List"
},
{
"tag": "CreateField",
"model": "User",
"field": "favoriteArticles",
"type": "Article",
"arity": "List"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "favoriteArticles"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "User",
"field": "favoriteArticles"
},
"directive": "relation"
},
"argument": "",
"value": "\"FavoritedArticles\""
},
{
"tag": "CreateModel",
"model": "Article"
},
{
"tag": "CreateField",
"model": "Article",
"field": "id",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "id"
},
"directive": "id"
}
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "id"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "id"
},
"directive": "default"
},
"argument": "",
"value": "autoincrement()"
},
{
"tag": "CreateField",
"model": "Article",
"field": "slug",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "slug"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "Article",
"field": "createdAt",
"type": "DateTime",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "createdAt"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "createdAt"
},
"directive": "default"
},
"argument": "",
"value": "now()"
},
{
"tag": "CreateField",
"model": "Article",
"field": "updatedAt",
"type": "DateTime",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "updatedAt"
},
"directive": "updatedAt"
}
},
{
"tag": "CreateField",
"model": "Article",
"field": "title",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Article",
"field": "description",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Article",
"field": "markdownContent",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Article",
"field": "user",
"type": "User",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "user"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "user"
},
"directive": "relation"
},
"argument": "fields",
"value": "[userId]"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "user"
},
"directive": "relation"
},
"argument": "references",
"value": "[id]"
},
{
"tag": "CreateField",
"model": "Article",
"field": "userId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Article",
"field": "comments",
"type": "Comment",
"arity": "List"
},
{
"tag": "CreateField",
"model": "Article",
"field": "tags",
"type": "ArticleTag",
"arity": "List"
},
{
"tag": "CreateField",
"model": "Article",
"field": "favoritedBy",
"type": "User",
"arity": "List"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Article",
"field": "favoritedBy"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Article",
"field": "favoritedBy"
},
"directive": "relation"
},
"argument": "",
"value": "\"FavoritedArticles\""
},
{
"tag": "CreateModel",
"model": "Comment"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "id",
"type": "Int",
"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": "autoincrement()"
},
{
"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": "content",
"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": "[userId]"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Comment",
"field": "user"
},
"directive": "relation"
},
"argument": "references",
"value": "[id]"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "userId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "article",
"type": "Article",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Comment",
"field": "article"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Comment",
"field": "article"
},
"directive": "relation"
},
"argument": "fields",
"value": "[articleId]"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Comment",
"field": "article"
},
"directive": "relation"
},
"argument": "references",
"value": "[id]"
},
{
"tag": "CreateField",
"model": "Comment",
"field": "articleId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateModel",
"model": "ArticleTag"
},
{
"tag": "CreateField",
"model": "ArticleTag",
"field": "name",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "ArticleTag",
"field": "name"
},
"directive": "id"
}
},
{
"tag": "CreateField",
"model": "ArticleTag",
"field": "articles",
"type": "Article",
"arity": "List"
}
]
}

View File

@ -1,11 +1,3 @@
# Prisma Migrate lockfile v1 # Prisma Migrate lockfile v1
20201030161549-user 20201127131647-init
20201030185724-fixed-user
20201117145436-added-bio-and-picture-to-user
20201119144622-added-article-entity
20201124192901-added-created-at-to-article
20201124195623-added-slug-to-article
20201124212222-added-comment
20201125134317-added-article-tag
20201126162628-added-favorite-articles