Skip to content

Commit

Permalink
Change DB and GraphQL Schema accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuflatland-lf committed Jul 8, 2024
1 parent 91eb954 commit 2b706eb
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 3,562 deletions.
1 change: 1 addition & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ parsergen: ## Generate Card data parser
printf "${GREEN}Generate parser.go\n\n${WHITE}"; \
go install golang.org/x/tools/cmd/goyacc@master ; \
goyacc -o ./pkg/notion/parser.go -p yy ./pkg/notion/parser.y; \
rm -fR y.output; \
printf "${GREEN}Done\n${WHITE}"; \

.PHONY: help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

CREATE TABLE users
(
id VARCHAR(255) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE cardgroups
(
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
name TEXT NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Expand All @@ -36,7 +36,7 @@ CREATE TABLE cards
CREATE TABLE cardgroups_users
(
cardgroup_id INTEGER NOT NULL,
user_id VARCHAR(255) NOT NULL,
user_id TEXT NOT NULL,
PRIMARY KEY (cardgroup_id, user_id),
FOREIGN KEY (cardgroup_id) REFERENCES cardgroups (id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
Expand All @@ -45,12 +45,12 @@ CREATE TABLE cardgroups_users
CREATE TABLE roles
(
id SERIAL PRIMARY KEY,
name VARCHAR(50) NOT NULL UNIQUE
name TEXT NOT NULL UNIQUE
);

CREATE TABLE users_roles
(
user_id VARCHAR(255) NOT NULL,
user_id TEXT NOT NULL,
role_id INTEGER NOT NULL,
PRIMARY KEY (user_id, role_id),
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
Expand Down
151 changes: 151 additions & 0 deletions backend/graph/generated.go

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

5 changes: 5 additions & 0 deletions backend/graph/model/models_gen.go

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

6 changes: 5 additions & 1 deletion backend/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ type User {
roles: [Role!]!
}

type CardGroupUser {
cardgroup_id: ID!
user_id: ID!
}

input NewCard {
front: String!
Expand Down Expand Up @@ -92,4 +96,4 @@ type Mutation {

assignRoleToUser(userId: ID!, roleId: ID!): Boolean!
removeRoleFromUser(userId: ID!, roleId: ID!): Boolean!
}
}
9 changes: 9 additions & 0 deletions backend/pkg/notion/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ opaque 不透明な
trot up 自慢げに歩かせて見せる、出して見せる、披露(ひろう)する、持ち出す、口にする
wriggle out of ~からうまく[何とか]切り抜ける
get under someone's skin 「(人)の気[癇]に障る、(人)をひどく怒らせる、(人)をイライラ
leeway 〔自分の好きなように行動・思考できる〕自由(裁量)度◆不可〔時間・金などの〕余裕、ゆとり
There is no leeway to provide services free of charge for the sake of others. 他人のために無償でサービスをする余裕はない。
`

// Define the test cases
Expand All @@ -36,6 +42,9 @@ var testCases = []struct {
{Word: "opaque", Definition: "不透明な"},
{Word: "trot up", Definition: "自慢げに歩かせて見せる、出して見せる、披露(ひろう)する、持ち出す、口にする"},
{Word: "wriggle out of", Definition: "~からうまく[何とか]切り抜ける"},
{Word: "get under someone's skin", Definition: "「(人)の気[癇]に障る、(人)をひどく怒らせる、(人)をイライラ"},
{Word: "leeway", Definition: "〔自分の好きなように行動・思考できる〕自由(裁量)度◆不可〔時間・金などの〕余裕、ゆとり"},
{Word: "There is no leeway to provide services free of charge for the sake of others.", Definition: "他人のために無償でサービスをする余裕はない。"},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/repository/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func setupTestDB(ctx context.Context) (*Postgres, func(), error) {
req := testcontainers.ContainerRequest{
Image: "postgres:13",
Image: "postgres:latest",
ExposedPorts: []string{"5432/tcp"},
Env: map[string]string{
"POSTGRES_USER": "testuser",
Expand Down
Loading

0 comments on commit 2b706eb

Please sign in to comment.