Skip to content

Commit

Permalink
update ERD
Browse files Browse the repository at this point in the history
  • Loading branch information
susumutomita committed May 20, 2024
1 parent f4da6e9 commit c8be7ef
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/check_er.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Pull Request Check

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
- name: makeERD
run: |
npm run db:generate
- id: checkErdDiff
run: echo "changed=$(git diff --name-only src/app/prisma/ERD.md)" >> $GITHUB_OUTPUT
- run: echo ${{ steps.checkErdDiff.outputs.changed}}
- if: ${{ steps.checkErdDiff.outputs.changed != '' }}
run: |
echo "ERD.md has changed.Please update ERD.md and commit it."
exit 1
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"seed": "ts-node src/app/prisma/seed.ts"
},
"devDependencies": {
"@mermaid-js/mermaid-cli": "^10.9.0",
"@prisma/generator-helper": "^5.14.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.3.0",
"@types/jest": "^29.5.12",
Expand Down
42 changes: 42 additions & 0 deletions src/app/prisma/ERD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
```mermaid
erDiagram
"Post" {
Int id "🗝️"
DateTime createdAt
DateTime updatedAt
String title
String body "❓"
Boolean draft
Boolean notice
String scope
DateTime publishedAt "❓"
Int authorId
}
"User" {
Int id "🗝️"
String email
String name "❓"
}
"Tag" {
Int id "🗝️"
String name
}
"PostTag" {
Int postId "🗝️"
Int tagId "🗝️"
}
"Post" o|--|| "User" : "author"
"Post" o{--}o "PostTag" : "tags"
"User" o{--}o "Post" : "posts"
"Tag" o{--}o "PostTag" : "posts"
"PostTag" o|--|| "Post" : "post"
"PostTag" o|--|| "Tag" : "tag"
```
1 change: 0 additions & 1 deletion src/app/prisma/ERD.svg

This file was deleted.

4 changes: 3 additions & 1 deletion src/app/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ generator client {

generator erd {
provider = "prisma-erd-generator"
output = "ERD.svg"
theme = "forest"
output = "ERD.md"
includeRelationFromFields = true
}

datasource db {
Expand Down

0 comments on commit c8be7ef

Please sign in to comment.