From 1a1805c7609fa863c371934348650436a8a53025 Mon Sep 17 00:00:00 2001 From: ZOI-dayo Date: Fri, 13 Dec 2024 01:28:22 +0900 Subject: [PATCH 1/5] migrate db --- internal/infrastructure/migration/current.go | 1 + internal/infrastructure/migration/v3.go | 46 +++++++++++++++++++ .../infrastructure/repository/model/user.go | 2 + 3 files changed, 49 insertions(+) create mode 100644 internal/infrastructure/migration/v3.go diff --git a/internal/infrastructure/migration/current.go b/internal/infrastructure/migration/current.go index 08e562fe..cee17873 100644 --- a/internal/infrastructure/migration/current.go +++ b/internal/infrastructure/migration/current.go @@ -10,6 +10,7 @@ func Migrations() []*gormigrate.Migration { return []*gormigrate.Migration{ v1(), v2(), // プロジェクト名とコンテスト名の重複禁止と文字数制限増加(32->128) + v3(), // ユーザーにDisplayNameを追加 } } diff --git a/internal/infrastructure/migration/v3.go b/internal/infrastructure/migration/v3.go new file mode 100644 index 00000000..805cc398 --- /dev/null +++ b/internal/infrastructure/migration/v3.go @@ -0,0 +1,46 @@ +// Package migration migrate current struct +package migration + +import ( + "database/sql" + "github.com/traPtitech/traPortfolio/internal/domain" + "time" + + "github.com/go-gormigrate/gormigrate/v2" + "github.com/gofrs/uuid" + "github.com/traPtitech/traPortfolio/internal/infrastructure/repository/model" + "gorm.io/gorm" +) + +// v3 UserにdisplayNameを追加 +func v3() *gormigrate.Migration { + return &gormigrate.Migration{ + ID: "3", + Migrate: func(db *gorm.DB) error { + if err := db.AutoMigrate(&v3User{}); err != nil { + return err + } + + return db. + Table("portfolio"). + Error + }, + } +} + +type v3User struct { + ID uuid.UUID `gorm:"type:char(36);not null;primaryKey"` + Description string `gorm:"type:text;not null"` + Check bool `gorm:"type:boolean;not null;default:false"` + Name string `gorm:"type:varchar(32);not null;unique"` + DisplayName sql.NullString `gorm:"type:varchar(32)"` // 追加 + State domain.TraQState `gorm:"type:tinyint(1);not null"` + CreatedAt time.Time `gorm:"precision:6"` + UpdatedAt time.Time `gorm:"precision:6"` + + Accounts []*model.Account `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` +} + +func (*v3User) TableName() string { + return "projects" +} diff --git a/internal/infrastructure/repository/model/user.go b/internal/infrastructure/repository/model/user.go index 999f3bda..865c0538 100644 --- a/internal/infrastructure/repository/model/user.go +++ b/internal/infrastructure/repository/model/user.go @@ -1,6 +1,7 @@ package model import ( + "database/sql" "time" "github.com/gofrs/uuid" @@ -12,6 +13,7 @@ type User struct { Description string `gorm:"type:text;not null"` Check bool `gorm:"type:boolean;not null;default:false"` Name string `gorm:"type:varchar(32);not null;unique"` + DisplayName sql.NullString `gorm:"type:varchar(32)"` State domain.TraQState `gorm:"type:tinyint(1);not null"` CreatedAt time.Time `gorm:"precision:6"` UpdatedAt time.Time `gorm:"precision:6"` From 0c39947d848cd5d4ef5208374c3deb6ec6f46ad3 Mon Sep 17 00:00:00 2001 From: ZOI-dayo Date: Fri, 13 Dec 2024 01:29:21 +0900 Subject: [PATCH 2/5] update documents --- docs/dbschema/README.md | 16 ++++++++-------- docs/dbschema/accounts.md | 1 + docs/dbschema/contest_team_user_belongings.md | 3 ++- docs/dbschema/contest_teams.md | 8 ++++---- docs/dbschema/contests.md | 8 ++++---- docs/dbschema/group_user_belongings.md | 1 + docs/dbschema/project_members.md | 18 +++++++----------- docs/dbschema/projects.md | 11 +++++------ docs/dbschema/schema.json | 2 +- docs/dbschema/users.md | 8 +++++--- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/dbschema/README.md b/docs/dbschema/README.md index b2c976c1..6511748a 100644 --- a/docs/dbschema/README.md +++ b/docs/dbschema/README.md @@ -14,8 +14,8 @@ | [group_user_belongings](group_user_belongings.md) | 8 | グループとユーザー関係テーブル | BASE TABLE | | [migrations](migrations.md) | 1 | gormigrate用のデータベースバージョンテーブル | BASE TABLE | | [projects](projects.md) | 10 | プロジェクトテーブル | BASE TABLE | -| [project_members](project_members.md) | 9 | プロジェクト所属者テーブル | BASE TABLE | -| [users](users.md) | 7 | ユーザーテーブル | BASE TABLE | +| [project_members](project_members.md) | 8 | プロジェクト所属者テーブル | BASE TABLE | +| [users](users.md) | 8 | ユーザーテーブル | BASE TABLE | ## Relations @@ -44,7 +44,7 @@ erDiagram } "contests" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link datetime_6_ since @@ -55,7 +55,7 @@ erDiagram "contest_teams" { char_36_ id PK char_36_ contest_id FK - varchar_32_ name + varchar_128_ name text description text result text link @@ -103,7 +103,7 @@ erDiagram } "projects" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link smallint_4_ since_year @@ -114,9 +114,8 @@ erDiagram datetime_6_ updated_at } "project_members" { - char_36_ id PK - char_36_ project_id FK - char_36_ user_id FK + char_36_ project_id PK + char_36_ user_id PK smallint_4_ since_year tinyint_1_ since_semester smallint_4_ until_year @@ -129,6 +128,7 @@ erDiagram text description tinyint_1_ check varchar_32_ name + varchar_32_ display_name tinyint_1_ state datetime_6_ created_at datetime_6_ updated_at diff --git a/docs/dbschema/accounts.md b/docs/dbschema/accounts.md index 718e2824..3834d164 100644 --- a/docs/dbschema/accounts.md +++ b/docs/dbschema/accounts.md @@ -74,6 +74,7 @@ erDiagram text description tinyint_1_ check varchar_32_ name + varchar_32_ display_name tinyint_1_ state datetime_6_ created_at datetime_6_ updated_at diff --git a/docs/dbschema/contest_team_user_belongings.md b/docs/dbschema/contest_team_user_belongings.md index 280f9e81..3c58b332 100644 --- a/docs/dbschema/contest_team_user_belongings.md +++ b/docs/dbschema/contest_team_user_belongings.md @@ -63,7 +63,7 @@ erDiagram "contest_teams" { char_36_ id PK char_36_ contest_id FK - varchar_32_ name + varchar_128_ name text description text result text link @@ -75,6 +75,7 @@ erDiagram text description tinyint_1_ check varchar_32_ name + varchar_32_ display_name tinyint_1_ state datetime_6_ created_at datetime_6_ updated_at diff --git a/docs/dbschema/contest_teams.md b/docs/dbschema/contest_teams.md index c87e265c..20f997c3 100644 --- a/docs/dbschema/contest_teams.md +++ b/docs/dbschema/contest_teams.md @@ -11,7 +11,7 @@ CREATE TABLE `contest_teams` ( `id` char(36) NOT NULL, `contest_id` char(36) NOT NULL, - `name` varchar(32) DEFAULT NULL, + `name` varchar(128) DEFAULT NULL, `description` text DEFAULT NULL, `result` text DEFAULT NULL, `link` text DEFAULT NULL, @@ -31,7 +31,7 @@ CREATE TABLE `contest_teams` ( | ---- | ---- | ------- | -------- | -------- | ------- | ------- | | id | char(36) | | false | [contest_team_user_belongings](contest_team_user_belongings.md) | | コンテストチームUUID | | contest_id | char(36) | | false | | [contests](contests.md) | コンテストUUID | -| name | varchar(32) | NULL | true | | | チーム名 | +| name | varchar(128) | NULL | true | | | チーム名 | | description | text | NULL | true | | | チーム情報 | | result | text | NULL | true | | | 順位などの結果 | | link | text | NULL | true | | | コンテストチームの詳細が載っているページへのリンク | @@ -63,7 +63,7 @@ erDiagram "contest_teams" { char_36_ id PK char_36_ contest_id FK - varchar_32_ name + varchar_128_ name text description text result text link @@ -78,7 +78,7 @@ erDiagram } "contests" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link datetime_6_ since diff --git a/docs/dbschema/contests.md b/docs/dbschema/contests.md index cc88df90..5a0d53cd 100644 --- a/docs/dbschema/contests.md +++ b/docs/dbschema/contests.md @@ -10,7 +10,7 @@ ```sql CREATE TABLE `contests` ( `id` char(36) NOT NULL, - `name` varchar(32) DEFAULT NULL, + `name` varchar(128) DEFAULT NULL, `description` text DEFAULT NULL, `link` text DEFAULT NULL, `since` datetime(6) DEFAULT NULL, @@ -28,7 +28,7 @@ CREATE TABLE `contests` ( | Name | Type | Default | Nullable | Children | Parents | Comment | | ---- | ---- | ------- | -------- | -------- | ------- | ------- | | id | char(36) | | false | [contest_teams](contest_teams.md) | | コンテストUUID | -| name | varchar(32) | NULL | true | | | コンテスト名 | +| name | varchar(128) | NULL | true | | | コンテスト名 | | description | text | NULL | true | | | コンテスト説明 | | link | text | NULL | true | | | コンテスト情報のリンク | | since | datetime(6) | NULL | true | | | 期間始まり | @@ -57,7 +57,7 @@ erDiagram "contests" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link datetime_6_ since @@ -68,7 +68,7 @@ erDiagram "contest_teams" { char_36_ id PK char_36_ contest_id FK - varchar_32_ name + varchar_128_ name text description text result text link diff --git a/docs/dbschema/group_user_belongings.md b/docs/dbschema/group_user_belongings.md index b3e1c4aa..c01b5c04 100644 --- a/docs/dbschema/group_user_belongings.md +++ b/docs/dbschema/group_user_belongings.md @@ -77,6 +77,7 @@ erDiagram text description tinyint_1_ check varchar_32_ name + varchar_32_ display_name tinyint_1_ state datetime_6_ created_at datetime_6_ updated_at diff --git a/docs/dbschema/project_members.md b/docs/dbschema/project_members.md index c2b99093..57eeed92 100644 --- a/docs/dbschema/project_members.md +++ b/docs/dbschema/project_members.md @@ -9,7 +9,6 @@ ```sql CREATE TABLE `project_members` ( - `id` char(36) NOT NULL, `project_id` char(36) NOT NULL, `user_id` char(36) NOT NULL, `since_year` smallint(4) NOT NULL, @@ -18,8 +17,7 @@ CREATE TABLE `project_members` ( `until_semester` tinyint(1) NOT NULL, `created_at` datetime(6) DEFAULT NULL, `updated_at` datetime(6) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `fk_project_members_project` (`project_id`), + PRIMARY KEY (`project_id`,`user_id`), KEY `fk_project_members_user` (`user_id`), CONSTRAINT `fk_project_members_project` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_project_members_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -32,7 +30,6 @@ CREATE TABLE `project_members` ( | Name | Type | Default | Nullable | Children | Parents | Comment | | ---- | ---- | ------- | -------- | -------- | ------- | ------- | -| id | char(36) | | false | | | | | project_id | char(36) | | false | | [projects](projects.md) | プロジェクトUUID | | user_id | char(36) | | false | | [users](users.md) | ユーザーUUID | | since_year | smallint(4) | | false | | | プロジェクト所属開始年 | @@ -48,15 +45,14 @@ CREATE TABLE `project_members` ( | ---- | ---- | ---------- | | fk_project_members_project | FOREIGN KEY | FOREIGN KEY (project_id) REFERENCES projects (id) | | fk_project_members_user | FOREIGN KEY | FOREIGN KEY (user_id) REFERENCES users (id) | -| PRIMARY | PRIMARY KEY | PRIMARY KEY (id) | +| PRIMARY | PRIMARY KEY | PRIMARY KEY (project_id, user_id) | ## Indexes | Name | Definition | | ---- | ---------- | -| fk_project_members_project | KEY fk_project_members_project (project_id) USING BTREE | | fk_project_members_user | KEY fk_project_members_user (user_id) USING BTREE | -| PRIMARY | PRIMARY KEY (id) USING BTREE | +| PRIMARY | PRIMARY KEY (project_id, user_id) USING BTREE | ## Relations @@ -67,9 +63,8 @@ erDiagram "project_members" }o--|| "users" : "FOREIGN KEY (user_id) REFERENCES users (id)" "project_members" { - char_36_ id PK - char_36_ project_id FK - char_36_ user_id FK + char_36_ project_id PK + char_36_ user_id PK smallint_4_ since_year tinyint_1_ since_semester smallint_4_ until_year @@ -79,7 +74,7 @@ erDiagram } "projects" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link smallint_4_ since_year @@ -94,6 +89,7 @@ erDiagram text description tinyint_1_ check varchar_32_ name + varchar_32_ display_name tinyint_1_ state datetime_6_ created_at datetime_6_ updated_at diff --git a/docs/dbschema/projects.md b/docs/dbschema/projects.md index 70aeb6da..3353f4b7 100644 --- a/docs/dbschema/projects.md +++ b/docs/dbschema/projects.md @@ -10,7 +10,7 @@ ```sql CREATE TABLE `projects` ( `id` char(36) NOT NULL, - `name` varchar(32) DEFAULT NULL, + `name` varchar(128) DEFAULT NULL, `description` text DEFAULT NULL, `link` text DEFAULT NULL, `since_year` smallint(4) NOT NULL, @@ -30,7 +30,7 @@ CREATE TABLE `projects` ( | Name | Type | Default | Nullable | Children | Parents | Comment | | ---- | ---- | ------- | -------- | -------- | ------- | ------- | | id | char(36) | | false | [project_members](project_members.md) | | プロジェクトUUID | -| name | varchar(32) | NULL | true | | | プロジェクト名 | +| name | varchar(128) | NULL | true | | | プロジェクト名 | | description | text | NULL | true | | | プロジェクト説明 | | link | text | NULL | true | | | プロジェクト情報のリンク | | since_year | smallint(4) | | false | | | プロジェクト開始年 | @@ -61,7 +61,7 @@ erDiagram "projects" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link smallint_4_ since_year @@ -72,9 +72,8 @@ erDiagram datetime_6_ updated_at } "project_members" { - char_36_ id PK - char_36_ project_id FK - char_36_ user_id FK + char_36_ project_id PK + char_36_ user_id PK smallint_4_ since_year tinyint_1_ since_semester smallint_4_ until_year diff --git a/docs/dbschema/schema.json b/docs/dbschema/schema.json index 23017333..cd5d66f1 100644 --- a/docs/dbschema/schema.json +++ b/docs/dbschema/schema.json @@ -1 +1 @@ -{"name":"portfolio","desc":"","tables":[{"name":"accounts","type":"BASE TABLE","comment":"Twitterなどのアカウントテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"アカウントUUID"},{"name":"type","type":"tinyint(1)","nullable":false,"default":null,"comment":"アカウントのハードコードID"},{"name":"name","type":"varchar(256)","nullable":true,"default":"NULL","comment":"アカウント名"},{"name":"url","type":"text","nullable":true,"default":"NULL","comment":"アカウントのURL"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"公開可能かどうか"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_users_accounts","def":"KEY fk_users_accounts (user_id) USING BTREE","table":"accounts","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"accounts","columns":["id"],"comment":""}],"constraints":[{"name":"fk_users_accounts","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"accounts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"accounts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `accounts` (\n `id` char(36) NOT NULL,\n `type` tinyint(1) NOT NULL,\n `name` varchar(256) DEFAULT NULL,\n `url` text DEFAULT NULL,\n `user_id` char(36) NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_users_accounts` (`user_id`),\n CONSTRAINT `fk_users_accounts` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contests","type":"BASE TABLE","comment":"コンテストテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"コンテスト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"コンテスト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテスト情報のリンク"},{"name":"since","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間始まり"},{"name":"until","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間終わり"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contests","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contests","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contests` (\n `id` char(36) NOT NULL,\n `name` varchar(32) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since` datetime(6) DEFAULT NULL,\n `until` datetime(6) DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_teams","type":"BASE TABLE","comment":"コンテスト参加チームテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"contest_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"チーム名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"チーム情報"},{"name":"result","type":"text","nullable":true,"default":"NULL","comment":"順位などの結果"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテストチームの詳細が載っているページへのリンク"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム更新日時"}],"indexes":[{"name":"fk_contest_teams_contest","def":"KEY fk_contest_teams_contest (contest_id) USING BTREE","table":"contest_teams","columns":["contest_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contest_teams","columns":["id"],"comment":""}],"constraints":[{"name":"fk_contest_teams_contest","type":"FOREIGN KEY","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","table":"contest_teams","referenced_table":"contests","columns":["contest_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contest_teams","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_teams` (\n `id` char(36) NOT NULL,\n `contest_id` char(36) NOT NULL,\n `name` varchar(32) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `result` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_contest_teams_contest` (`contest_id`),\n CONSTRAINT `fk_contest_teams_contest` FOREIGN KEY (`contest_id`) REFERENCES `contests` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_team_user_belongings","type":"BASE TABLE","comment":"コンテストチームとユーザー関係テーブル","columns":[{"name":"team_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_contest_team_user_belongings_user","def":"KEY fk_contest_team_user_belongings_user (user_id) USING BTREE","table":"contest_team_user_belongings","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (team_id, user_id) USING BTREE","table":"contest_team_user_belongings","columns":["team_id","user_id"],"comment":""}],"constraints":[{"name":"fk_contest_team_user_belongings_contest_team","type":"FOREIGN KEY","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","table":"contest_team_user_belongings","referenced_table":"contest_teams","columns":["team_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_contest_team_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"contest_team_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (team_id, user_id)","table":"contest_team_user_belongings","referenced_table":null,"columns":["team_id","user_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_team_user_belongings` (\n `team_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`team_id`,`user_id`),\n KEY `fk_contest_team_user_belongings_user` (`user_id`),\n CONSTRAINT `fk_contest_team_user_belongings_contest_team` FOREIGN KEY (`team_id`) REFERENCES `contest_teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_contest_team_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"event_level_relations","type":"BASE TABLE","comment":"knoQイベントと公開レベルの関係テーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"knoQイベントUUID"},{"name":"level","type":"tinyint(3) unsigned","nullable":false,"default":"0","comment":"公開レベル。0なら匿名、1ならそのまま公開、2なら外部に非公開"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"event_level_relations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"event_level_relations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `event_level_relations` (\n `id` char(36) NOT NULL,\n `level` tinyint(3) unsigned NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"groups","type":"BASE TABLE","comment":"グループテーブル","columns":[{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"グループ名"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"グループのリンク"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"グループの説明文"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (group_id) USING BTREE","table":"groups","columns":["group_id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (group_id)","table":"groups","referenced_table":null,"columns":["group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `groups` (\n `group_id` char(36) NOT NULL,\n `name` varchar(32) DEFAULT NULL,\n `link` text DEFAULT NULL,\n `description` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`group_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_admins","type":"BASE TABLE","comment":"グループと管理者関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_admins_group","def":"KEY fk_group_user_admins_group (group_id) USING BTREE","table":"group_user_admins","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_admins","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_admins_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_admins","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_admins","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_admins` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_admins_group` (`group_id`),\n CONSTRAINT `fk_group_user_admins_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_belongings","type":"BASE TABLE","comment":"グループとユーザー関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_belongings_group","def":"KEY fk_group_user_belongings_group (group_id) USING BTREE","table":"group_user_belongings","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_belongings","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_belongings_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_belongings","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"fk_group_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"group_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_belongings","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_belongings` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_belongings_group` (`group_id`),\n CONSTRAINT `fk_group_user_belongings_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_group_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"migrations","type":"BASE TABLE","comment":"gormigrate用のデータベースバージョンテーブル","columns":[{"name":"id","type":"varchar(255)","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"migrations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"migrations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `migrations` (\n `id` varchar(255) NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"projects","type":"BASE TABLE","comment":"プロジェクトテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"プロジェクト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト情報のリンク"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"projects","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"projects","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `projects` (\n `id` char(36) NOT NULL,\n `name` varchar(32) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"project_members","type":"BASE TABLE","comment":"プロジェクト所属者テーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":""},{"name":"project_id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_project_members_project","def":"KEY fk_project_members_project (project_id) USING BTREE","table":"project_members","columns":["project_id"],"comment":""},{"name":"fk_project_members_user","def":"KEY fk_project_members_user (user_id) USING BTREE","table":"project_members","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"project_members","columns":["id"],"comment":""}],"constraints":[{"name":"fk_project_members_project","type":"FOREIGN KEY","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","table":"project_members","referenced_table":"projects","columns":["project_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_project_members_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"project_members","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"project_members","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `project_members` (\n `id` char(36) NOT NULL,\n `project_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_project_members_project` (`project_id`),\n KEY `fk_project_members_user` (`user_id`),\n CONSTRAINT `fk_project_members_project` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_project_members_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"users","type":"BASE TABLE","comment":"ユーザーテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"description","type":"text","nullable":false,"default":null,"comment":"自己紹介文"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"氏名を公開するかどうかの可否 (0: 停止, 1: 有効, 2: 一時停止)"},{"name":"name","type":"varchar(32)","nullable":false,"default":null,"comment":"ユーザー名"},{"name":"state","type":"tinyint(1)","nullable":false,"default":null,"comment":"traQのユーザーアカウント状態"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"users","columns":["id"],"comment":""},{"name":"uni_users_name","def":"UNIQUE KEY uni_users_name (name) USING BTREE","table":"users","columns":["name"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"uni_users_name","type":"UNIQUE","def":"UNIQUE KEY uni_users_name (name)","table":"users","referenced_table":null,"columns":["name"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `users` (\n `id` char(36) NOT NULL,\n `description` text NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `name` varchar(32) NOT NULL,\n `state` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `uni_users_name` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"}],"relations":[{"table":"accounts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"contest_teams","columns":["contest_id"],"cardinality":"Zero or more","parent_table":"contests","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["team_id"],"cardinality":"Zero or more","parent_table":"contest_teams","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"group_user_admins","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"project_members","columns":["project_id"],"cardinality":"Zero or more","parent_table":"projects","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","virtual":false},{"table":"project_members","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false}],"functions":[],"driver":{"name":"mariadb","database_version":"10.6.4-MariaDB-1:10.6.4+maria~focal","meta":{"dict":{"Functions":"Stored procedures and functions"}}}} +{"name":"portfolio","desc":"","tables":[{"name":"accounts","type":"BASE TABLE","comment":"Twitterなどのアカウントテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"アカウントUUID"},{"name":"type","type":"tinyint(1)","nullable":false,"default":null,"comment":"アカウントのハードコードID"},{"name":"name","type":"varchar(256)","nullable":true,"default":"NULL","comment":"アカウント名"},{"name":"url","type":"text","nullable":true,"default":"NULL","comment":"アカウントのURL"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"公開可能かどうか"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_users_accounts","def":"KEY fk_users_accounts (user_id) USING BTREE","table":"accounts","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"accounts","columns":["id"],"comment":""}],"constraints":[{"name":"fk_users_accounts","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"accounts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"accounts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `accounts` (\n `id` char(36) NOT NULL,\n `type` tinyint(1) NOT NULL,\n `name` varchar(256) DEFAULT NULL,\n `url` text DEFAULT NULL,\n `user_id` char(36) NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_users_accounts` (`user_id`),\n CONSTRAINT `fk_users_accounts` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contests","type":"BASE TABLE","comment":"コンテストテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"コンテスト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"コンテスト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテスト情報のリンク"},{"name":"since","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間始まり"},{"name":"until","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間終わり"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contests","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contests","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contests` (\n `id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since` datetime(6) DEFAULT NULL,\n `until` datetime(6) DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_teams","type":"BASE TABLE","comment":"コンテスト参加チームテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"contest_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"チーム名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"チーム情報"},{"name":"result","type":"text","nullable":true,"default":"NULL","comment":"順位などの結果"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテストチームの詳細が載っているページへのリンク"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム更新日時"}],"indexes":[{"name":"fk_contest_teams_contest","def":"KEY fk_contest_teams_contest (contest_id) USING BTREE","table":"contest_teams","columns":["contest_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contest_teams","columns":["id"],"comment":""}],"constraints":[{"name":"fk_contest_teams_contest","type":"FOREIGN KEY","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","table":"contest_teams","referenced_table":"contests","columns":["contest_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contest_teams","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_teams` (\n `id` char(36) NOT NULL,\n `contest_id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `result` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_contest_teams_contest` (`contest_id`),\n CONSTRAINT `fk_contest_teams_contest` FOREIGN KEY (`contest_id`) REFERENCES `contests` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_team_user_belongings","type":"BASE TABLE","comment":"コンテストチームとユーザー関係テーブル","columns":[{"name":"team_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_contest_team_user_belongings_user","def":"KEY fk_contest_team_user_belongings_user (user_id) USING BTREE","table":"contest_team_user_belongings","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (team_id, user_id) USING BTREE","table":"contest_team_user_belongings","columns":["team_id","user_id"],"comment":""}],"constraints":[{"name":"fk_contest_team_user_belongings_contest_team","type":"FOREIGN KEY","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","table":"contest_team_user_belongings","referenced_table":"contest_teams","columns":["team_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_contest_team_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"contest_team_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (team_id, user_id)","table":"contest_team_user_belongings","referenced_table":null,"columns":["team_id","user_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_team_user_belongings` (\n `team_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`team_id`,`user_id`),\n KEY `fk_contest_team_user_belongings_user` (`user_id`),\n CONSTRAINT `fk_contest_team_user_belongings_contest_team` FOREIGN KEY (`team_id`) REFERENCES `contest_teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_contest_team_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"event_level_relations","type":"BASE TABLE","comment":"knoQイベントと公開レベルの関係テーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"knoQイベントUUID"},{"name":"level","type":"tinyint(3) unsigned","nullable":false,"default":"0","comment":"公開レベル。0なら匿名、1ならそのまま公開、2なら外部に非公開"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"event_level_relations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"event_level_relations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `event_level_relations` (\n `id` char(36) NOT NULL,\n `level` tinyint(3) unsigned NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"groups","type":"BASE TABLE","comment":"グループテーブル","columns":[{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"グループ名"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"グループのリンク"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"グループの説明文"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (group_id) USING BTREE","table":"groups","columns":["group_id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (group_id)","table":"groups","referenced_table":null,"columns":["group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `groups` (\n `group_id` char(36) NOT NULL,\n `name` varchar(32) DEFAULT NULL,\n `link` text DEFAULT NULL,\n `description` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`group_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_admins","type":"BASE TABLE","comment":"グループと管理者関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_admins_group","def":"KEY fk_group_user_admins_group (group_id) USING BTREE","table":"group_user_admins","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_admins","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_admins_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_admins","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_admins","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_admins` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_admins_group` (`group_id`),\n CONSTRAINT `fk_group_user_admins_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_belongings","type":"BASE TABLE","comment":"グループとユーザー関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_belongings_group","def":"KEY fk_group_user_belongings_group (group_id) USING BTREE","table":"group_user_belongings","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_belongings","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_belongings_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_belongings","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"fk_group_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"group_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_belongings","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_belongings` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_belongings_group` (`group_id`),\n CONSTRAINT `fk_group_user_belongings_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_group_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"migrations","type":"BASE TABLE","comment":"gormigrate用のデータベースバージョンテーブル","columns":[{"name":"id","type":"varchar(255)","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"migrations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"migrations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `migrations` (\n `id` varchar(255) NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"projects","type":"BASE TABLE","comment":"プロジェクトテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"プロジェクト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト情報のリンク"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"projects","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"projects","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `projects` (\n `id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"project_members","type":"BASE TABLE","comment":"プロジェクト所属者テーブル","columns":[{"name":"project_id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_project_members_user","def":"KEY fk_project_members_user (user_id) USING BTREE","table":"project_members","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (project_id, user_id) USING BTREE","table":"project_members","columns":["project_id","user_id"],"comment":""}],"constraints":[{"name":"fk_project_members_project","type":"FOREIGN KEY","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","table":"project_members","referenced_table":"projects","columns":["project_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_project_members_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"project_members","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (project_id, user_id)","table":"project_members","referenced_table":null,"columns":["project_id","user_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `project_members` (\n `project_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`project_id`,`user_id`),\n KEY `fk_project_members_user` (`user_id`),\n CONSTRAINT `fk_project_members_project` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_project_members_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"users","type":"BASE TABLE","comment":"ユーザーテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"description","type":"text","nullable":false,"default":null,"comment":"自己紹介文"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"氏名を公開するかどうかの可否 (0: 停止, 1: 有効, 2: 一時停止)"},{"name":"name","type":"varchar(32)","nullable":false,"default":null,"comment":"ユーザー名"},{"name":"display_name","type":"varchar(32)","nullable":true,"default":"NULL","comment":""},{"name":"state","type":"tinyint(1)","nullable":false,"default":null,"comment":"traQのユーザーアカウント状態"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"users","columns":["id"],"comment":""},{"name":"uni_users_name","def":"UNIQUE KEY uni_users_name (name) USING BTREE","table":"users","columns":["name"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"uni_users_name","type":"UNIQUE","def":"UNIQUE KEY uni_users_name (name)","table":"users","referenced_table":null,"columns":["name"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `users` (\n `id` char(36) NOT NULL,\n `description` text NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `name` varchar(32) NOT NULL,\n `display_name` varchar(32) DEFAULT NULL,\n `state` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `uni_users_name` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"}],"relations":[{"table":"accounts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"contest_teams","columns":["contest_id"],"cardinality":"Zero or more","parent_table":"contests","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["team_id"],"cardinality":"Zero or more","parent_table":"contest_teams","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"group_user_admins","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"project_members","columns":["project_id"],"cardinality":"Zero or more","parent_table":"projects","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","virtual":false},{"table":"project_members","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false}],"functions":[],"driver":{"name":"mariadb","database_version":"10.6.4-MariaDB-1:10.6.4+maria~focal","meta":{"dict":{"Functions":"Stored procedures and functions"}}}} diff --git a/docs/dbschema/users.md b/docs/dbschema/users.md index e16b757b..07adeafc 100644 --- a/docs/dbschema/users.md +++ b/docs/dbschema/users.md @@ -13,6 +13,7 @@ CREATE TABLE `users` ( `description` text NOT NULL, `check` tinyint(1) NOT NULL DEFAULT 0, `name` varchar(32) NOT NULL, + `display_name` varchar(32) DEFAULT NULL, `state` tinyint(1) NOT NULL, `created_at` datetime(6) DEFAULT NULL, `updated_at` datetime(6) DEFAULT NULL, @@ -31,6 +32,7 @@ CREATE TABLE `users` ( | description | text | | false | | | 自己紹介文 | | check | tinyint(1) | 0 | false | | | 氏名を公開するかどうかの可否 (0: 停止, 1: 有効, 2: 一時停止) | | name | varchar(32) | | false | | | ユーザー名 | +| display_name | varchar(32) | NULL | true | | | | | state | tinyint(1) | | false | | | traQのユーザーアカウント状態 | | created_at | datetime(6) | NULL | true | | | | | updated_at | datetime(6) | NULL | true | | | | @@ -64,6 +66,7 @@ erDiagram text description tinyint_1_ check varchar_32_ name + varchar_32_ display_name tinyint_1_ state datetime_6_ created_at datetime_6_ updated_at @@ -95,9 +98,8 @@ erDiagram datetime_6_ updated_at } "project_members" { - char_36_ id PK - char_36_ project_id FK - char_36_ user_id FK + char_36_ project_id PK + char_36_ user_id PK smallint_4_ since_year tinyint_1_ since_semester smallint_4_ until_year From fd9f972f46a81b4af0cc46c176428b8940782431 Mon Sep 17 00:00:00 2001 From: ZOI-dayo Date: Thu, 19 Dec 2024 15:36:39 +0900 Subject: [PATCH 3/5] run generate command --- internal/handler/schema/schema_gen.go | 2 +- .../external/mock_external/mock_knoq.go | 1 + .../external/mock_external/mock_portal.go | 1 + .../external/mock_external/mock_traq.go | 1 + .../mock_contest_repository.go | 1 + .../mock_repository/mock_event_repository.go | 1 + .../mock_repository/mock_group_repository.go | 1 + .../mock_project_repository.go | 29 +++++++++++++++++-- .../mock_repository/mock_user_repository.go | 1 + 9 files changed, 35 insertions(+), 3 deletions(-) diff --git a/internal/handler/schema/schema_gen.go b/internal/handler/schema/schema_gen.go index 742bee89..a229151a 100644 --- a/internal/handler/schema/schema_gen.go +++ b/internal/handler/schema/schema_gen.go @@ -1,6 +1,6 @@ // Package schema provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT. package schema import ( diff --git a/internal/infrastructure/external/mock_external/mock_knoq.go b/internal/infrastructure/external/mock_external/mock_knoq.go index 538d20fd..8b249c47 100644 --- a/internal/infrastructure/external/mock_external/mock_knoq.go +++ b/internal/infrastructure/external/mock_external/mock_knoq.go @@ -21,6 +21,7 @@ import ( type MockKnoqAPI struct { ctrl *gomock.Controller recorder *MockKnoqAPIMockRecorder + isgomock struct{} } // MockKnoqAPIMockRecorder is the mock recorder for MockKnoqAPI. diff --git a/internal/infrastructure/external/mock_external/mock_portal.go b/internal/infrastructure/external/mock_external/mock_portal.go index a947de9d..bf0d5d96 100644 --- a/internal/infrastructure/external/mock_external/mock_portal.go +++ b/internal/infrastructure/external/mock_external/mock_portal.go @@ -20,6 +20,7 @@ import ( type MockPortalAPI struct { ctrl *gomock.Controller recorder *MockPortalAPIMockRecorder + isgomock struct{} } // MockPortalAPIMockRecorder is the mock recorder for MockPortalAPI. diff --git a/internal/infrastructure/external/mock_external/mock_traq.go b/internal/infrastructure/external/mock_external/mock_traq.go index ebada14d..651cb6a2 100644 --- a/internal/infrastructure/external/mock_external/mock_traq.go +++ b/internal/infrastructure/external/mock_external/mock_traq.go @@ -20,6 +20,7 @@ import ( type MockTraQAPI struct { ctrl *gomock.Controller recorder *MockTraQAPIMockRecorder + isgomock struct{} } // MockTraQAPIMockRecorder is the mock recorder for MockTraQAPI. diff --git a/internal/usecases/repository/mock_repository/mock_contest_repository.go b/internal/usecases/repository/mock_repository/mock_contest_repository.go index 51ab83be..705491be 100644 --- a/internal/usecases/repository/mock_repository/mock_contest_repository.go +++ b/internal/usecases/repository/mock_repository/mock_contest_repository.go @@ -23,6 +23,7 @@ import ( type MockContestRepository struct { ctrl *gomock.Controller recorder *MockContestRepositoryMockRecorder + isgomock struct{} } // MockContestRepositoryMockRecorder is the mock recorder for MockContestRepository. diff --git a/internal/usecases/repository/mock_repository/mock_event_repository.go b/internal/usecases/repository/mock_repository/mock_event_repository.go index 01b283b4..1799068f 100644 --- a/internal/usecases/repository/mock_repository/mock_event_repository.go +++ b/internal/usecases/repository/mock_repository/mock_event_repository.go @@ -23,6 +23,7 @@ import ( type MockEventRepository struct { ctrl *gomock.Controller recorder *MockEventRepositoryMockRecorder + isgomock struct{} } // MockEventRepositoryMockRecorder is the mock recorder for MockEventRepository. diff --git a/internal/usecases/repository/mock_repository/mock_group_repository.go b/internal/usecases/repository/mock_repository/mock_group_repository.go index aaf393ef..0eabb45a 100644 --- a/internal/usecases/repository/mock_repository/mock_group_repository.go +++ b/internal/usecases/repository/mock_repository/mock_group_repository.go @@ -22,6 +22,7 @@ import ( type MockGroupRepository struct { ctrl *gomock.Controller recorder *MockGroupRepositoryMockRecorder + isgomock struct{} } // MockGroupRepositoryMockRecorder is the mock recorder for MockGroupRepository. diff --git a/internal/usecases/repository/mock_repository/mock_project_repository.go b/internal/usecases/repository/mock_repository/mock_project_repository.go index 9626c3bb..5205ab26 100644 --- a/internal/usecases/repository/mock_repository/mock_project_repository.go +++ b/internal/usecases/repository/mock_repository/mock_project_repository.go @@ -23,6 +23,7 @@ import ( type MockProjectRepository struct { ctrl *gomock.Controller recorder *MockProjectRepositoryMockRecorder + isgomock struct{} } // MockProjectRepositoryMockRecorder is the mock recorder for MockProjectRepository. @@ -90,9 +91,33 @@ func (m *MockProjectRepository) DeleteProject(ctx context.Context, projectID uui } // DeleteProject indicates an expected call of DeleteProject. -func (mr *MockProjectRepositoryMockRecorder) DeleteProject(ctx, projectID interface{}) *gomock.Call { +func (mr *MockProjectRepositoryMockRecorder) DeleteProject(ctx, projectID any) *MockProjectRepositoryDeleteProjectCall { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteProject", reflect.TypeOf((*MockProjectRepository)(nil).DeleteProject), ctx, projectID) + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteProject", reflect.TypeOf((*MockProjectRepository)(nil).DeleteProject), ctx, projectID) + return &MockProjectRepositoryDeleteProjectCall{Call: call} +} + +// MockProjectRepositoryDeleteProjectCall wrap *gomock.Call +type MockProjectRepositoryDeleteProjectCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockProjectRepositoryDeleteProjectCall) Return(arg0 error) *MockProjectRepositoryDeleteProjectCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockProjectRepositoryDeleteProjectCall) Do(f func(context.Context, uuid.UUID) error) *MockProjectRepositoryDeleteProjectCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockProjectRepositoryDeleteProjectCall) DoAndReturn(f func(context.Context, uuid.UUID) error) *MockProjectRepositoryDeleteProjectCall { + c.Call = c.Call.DoAndReturn(f) + return c } // EditProjectMembers mocks base method. diff --git a/internal/usecases/repository/mock_repository/mock_user_repository.go b/internal/usecases/repository/mock_repository/mock_user_repository.go index 89ae579d..d9d4775d 100644 --- a/internal/usecases/repository/mock_repository/mock_user_repository.go +++ b/internal/usecases/repository/mock_repository/mock_user_repository.go @@ -23,6 +23,7 @@ import ( type MockUserRepository struct { ctrl *gomock.Controller recorder *MockUserRepositoryMockRecorder + isgomock struct{} } // MockUserRepositoryMockRecorder is the mock recorder for MockUserRepository. From e25793bdc37d4eff63f8718426b7cd1395b400f1 Mon Sep 17 00:00:00 2001 From: ZOI-dayo Date: Thu, 26 Dec 2024 16:22:25 +0900 Subject: [PATCH 4/5] add displayName property --- docs/swagger/traPortfolio.v1.yaml | 7 +++++ internal/domain/user.go | 20 +++++++------- internal/handler/contest.go | 6 ++--- internal/handler/contest_test.go | 26 +++++++++++-------- internal/handler/event.go | 2 +- internal/handler/event_test.go | 2 +- internal/handler/group.go | 4 +-- internal/handler/group_test.go | 4 +-- internal/handler/project.go | 4 +-- internal/handler/project_test.go | 2 +- internal/handler/schema/schema_gen.go | 15 +++++++++++ internal/handler/user.go | 15 ++++++----- internal/handler/user_test.go | 10 +++---- internal/infrastructure/migration/v3.go | 3 +-- .../infrastructure/repository/contest_impl.go | 6 ++--- .../infrastructure/repository/contest_test.go | 4 +-- .../infrastructure/repository/model/user.go | 3 +-- .../infrastructure/repository/project_impl.go | 2 ++ .../infrastructure/repository/project_test.go | 5 ++++ .../infrastructure/repository/user_impl.go | 3 +++ .../infrastructure/repository/user_test.go | 9 +++++++ internal/pkgs/mockdata/handler.go | 2 +- 22 files changed, 100 insertions(+), 54 deletions(-) diff --git a/docs/swagger/traPortfolio.v1.yaml b/docs/swagger/traPortfolio.v1.yaml index d8457692..20ea4935 100644 --- a/docs/swagger/traPortfolio.v1.yaml +++ b/docs/swagger/traPortfolio.v1.yaml @@ -767,10 +767,14 @@ components: realName: type: string description: 本名 + displayName: + type: string + description: 表示名 required: - id - name - realName + - displayName UserDetail: title: UserDetail type: object @@ -1292,6 +1296,9 @@ components: bio: type: string description: 自己紹介(biography) + displayName: + type: string + description: 表示名 check: type: boolean description: |- diff --git a/internal/domain/user.go b/internal/domain/user.go index cdb95968..cb96fef6 100644 --- a/internal/domain/user.go +++ b/internal/domain/user.go @@ -12,18 +12,20 @@ import ( ) type User struct { - ID uuid.UUID - Name string - realName string - Check bool + ID uuid.UUID + Name string + realName string + DisplayName string + Check bool } -func NewUser(id uuid.UUID, name string, realName string, check bool) *User { +func NewUser(id uuid.UUID, name string, realName string, displayName string, check bool) *User { return &User{ - ID: id, - Name: name, - realName: realName, - Check: check, + ID: id, + Name: name, + realName: realName, + DisplayName: displayName, + Check: check, } } diff --git a/internal/handler/contest.go b/internal/handler/contest.go index 64dec461..74e9f89a 100644 --- a/internal/handler/contest.go +++ b/internal/handler/contest.go @@ -64,7 +64,7 @@ func (h *ContestHandler) GetContest(c echo.Context) error { for i, v := range contest.ContestTeams { members := make([]schema.User, len(v.Members)) for j, ct := range v.Members { - members[j] = newUser(ct.ID, ct.Name, ct.RealName()) + members[j] = newUser(ct.ID, ct.Name, ct.RealName(), ct.DisplayName) } teams[i] = newContestTeam(v.ID, v.Name, v.Result, members) } @@ -168,7 +168,7 @@ func (h *ContestHandler) GetContestTeams(c echo.Context) error { for i, v := range contestTeams { members := make([]schema.User, len(v.Members)) for j, ct := range v.Members { - members[j] = newUser(ct.ID, ct.Name, ct.RealName()) + members[j] = newUser(ct.ID, ct.Name, ct.RealName(), ct.DisplayName) } res[i] = newContestTeam(v.ID, v.Name, v.Result, members) } @@ -205,7 +205,7 @@ func (h *ContestHandler) GetContestTeam(c echo.Context) error { members := make([]schema.User, len(contestTeam.Members)) for i, v := range contestTeam.Members { - members[i] = newUser(v.ID, v.Name, v.RealName()) + members[i] = newUser(v.ID, v.Name, v.RealName(), v.DisplayName) } res := newContestTeamDetail( diff --git a/internal/handler/contest_test.go b/internal/handler/contest_test.go index bdc5fda3..e8c75cb6 100644 --- a/internal/handler/contest_test.go +++ b/internal/handler/contest_test.go @@ -109,6 +109,7 @@ var ( } ) +//goland:noinspection Annotator,Annotator,Annotator,Annotator,Annotator,Annotator,Annotator,Annotator func makeContest(t *testing.T) (*domain.ContestDetail, *schema.ContestDetail) { t.Helper() @@ -131,8 +132,8 @@ func makeContest(t *testing.T) (*domain.ContestDetail, *schema.ContestDetail) { Result: random.AlphaNumeric(), }, Members: []*domain.User{ - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), }, }, { @@ -143,8 +144,8 @@ func makeContest(t *testing.T) (*domain.ContestDetail, *schema.ContestDetail) { Result: random.AlphaNumeric(), }, Members: []*domain.User{ - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), }, }, }, @@ -516,6 +517,7 @@ func TestContestHandler_DeleteContest(t *testing.T) { } } +//goland:noinspection Annotator,Annotator,Annotator,Annotator,Annotator,Annotator,Annotator,Annotator func TestContestHandler_GetContestTeams(t *testing.T) { t.Parallel() tests := []struct { @@ -536,8 +538,8 @@ func TestContestHandler_GetContestTeams(t *testing.T) { Result: random.AlphaNumeric(), }, Members: []*domain.User{ - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), }, }, { @@ -548,8 +550,8 @@ func TestContestHandler_GetContestTeams(t *testing.T) { Result: random.AlphaNumeric(), }, Members: []*domain.User{ - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), }, }, } @@ -603,6 +605,7 @@ func TestContestHandler_GetContestTeams(t *testing.T) { } } +//goland:noinspection Annotator,Annotator,Annotator,Annotator func TestContestHandler_GetContestTeam(t *testing.T) { t.Parallel() tests := []struct { @@ -624,8 +627,8 @@ func TestContestHandler_GetContestTeam(t *testing.T) { Result: random.AlphaNumeric(), }, Members: []*domain.User{ - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), }, }, Link: random.AlphaNumeric(), @@ -1015,6 +1018,7 @@ func TestContestHandler_PatchContestTeam(t *testing.T) { } } +//goland:noinspection Annotator,Annotator func TestContestHandler_GetContestTeamMembers(t *testing.T) { t.Parallel() tests := []struct { @@ -1028,7 +1032,7 @@ func TestContestHandler_GetContestTeamMembers(t *testing.T) { contestID := random.UUID() teamID := random.UUID() users := []*domain.User{ - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), } hres := make([]*schema.User, len(users)) for i, user := range users { diff --git a/internal/handler/event.go b/internal/handler/event.go index 4720fb76..135b5a82 100644 --- a/internal/handler/event.go +++ b/internal/handler/event.go @@ -73,7 +73,7 @@ func (h *EventHandler) GetEvent(c echo.Context) error { } hostname := make([]schema.User, len(event.HostName)) for i, v := range event.HostName { - hostname[i] = newUser(v.ID, v.Name, v.RealName()) + hostname[i] = newUser(v.ID, v.Name, v.RealName(), v.DisplayName) } return c.JSON(http.StatusOK, newEventDetail( diff --git a/internal/handler/event_test.go b/internal/handler/event_test.go index 9bcf3ded..74c609d0 100644 --- a/internal/handler/event_test.go +++ b/internal/handler/event_test.go @@ -110,7 +110,7 @@ func TestEventHandler_GetEvent(t *testing.T) { hHost := []schema.User{} for range hostnum { - rhost := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) + rhost := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) hhost := schema.User{ Id: rhost.ID, Name: rhost.Name, diff --git a/internal/handler/group.go b/internal/handler/group.go index 22564276..f45db5d1 100644 --- a/internal/handler/group.go +++ b/internal/handler/group.go @@ -85,13 +85,13 @@ func formatGetGroup(group *domain.GroupDetail) schema.GroupDetail { groupRes := make([]schema.GroupMember, len(group.Members)) for i, v := range group.Members { groupRes[i] = newGroupMember( - newUser(v.User.ID, v.User.Name, v.User.RealName()), + newUser(v.User.ID, v.User.Name, v.User.RealName(), v.User.DisplayName), schema.ConvertDuration(v.Duration), ) } adminRes := make([]schema.User, len(group.Admin)) for i, v := range group.Admin { - adminRes[i] = newUser(v.ID, v.Name, v.RealName()) + adminRes[i] = newUser(v.ID, v.Name, v.RealName(), v.DisplayName) } res := newGroupDetail( diff --git a/internal/handler/group_test.go b/internal/handler/group_test.go index eebb2543..b469587c 100644 --- a/internal/handler/group_test.go +++ b/internal/handler/group_test.go @@ -106,7 +106,7 @@ func TestGroupHandler_GetGroup(t *testing.T) { adminLen := rand.IntN(256) for range adminLen { - rgroupAdmin := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) + rgroupAdmin := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) hgroupAdmin := schema.User{ Id: rgroupAdmin.ID, @@ -124,7 +124,7 @@ func TestGroupHandler_GetGroup(t *testing.T) { groupLen := rand.IntN(256) for range groupLen { rgroupmember := domain.UserWithDuration{ - User: *domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + User: *domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), Duration: random.Duration(), } diff --git a/internal/handler/project.go b/internal/handler/project.go index 52a78a84..d41dda03 100644 --- a/internal/handler/project.go +++ b/internal/handler/project.go @@ -51,7 +51,7 @@ func (h *ProjectHandler) GetProject(c echo.Context) error { members := make([]schema.ProjectMember, len(project.Members)) for i, v := range project.Members { members[i] = newProjectMember( - newUser(v.User.ID, v.User.Name, v.User.RealName()), + newUser(v.User.ID, v.User.Name, v.User.RealName(), v.User.DisplayName), schema.ConvertDuration(v.Duration), ) } @@ -203,7 +203,7 @@ func (h *ProjectHandler) GetProjectMembers(c echo.Context) error { res := make([]schema.ProjectMember, len(members)) for i, v := range members { res[i] = newProjectMember( - newUser(v.User.ID, v.User.Name, v.User.RealName()), + newUser(v.User.ID, v.User.Name, v.User.RealName(), v.User.DisplayName), schema.ConvertDuration(v.Duration), ) } diff --git a/internal/handler/project_test.go b/internal/handler/project_test.go index 99fe2ae1..dcb01459 100644 --- a/internal/handler/project_test.go +++ b/internal/handler/project_test.go @@ -134,7 +134,7 @@ func TestProjectHandler_GetProject(t *testing.T) { Link: random.RandURLString(), Members: []*domain.UserWithDuration{ { - User: *domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + User: *domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), Duration: random.Duration(), }, }, diff --git a/internal/handler/schema/schema_gen.go b/internal/handler/schema/schema_gen.go index a229151a..fd3f1700 100644 --- a/internal/handler/schema/schema_gen.go +++ b/internal/handler/schema/schema_gen.go @@ -287,6 +287,9 @@ type EditUserRequest struct { // true: 公開 // false: 非公開 Check *bool `json:"check,omitempty"` + + // DisplayName 表示名 + DisplayName *string `json:"displayName,omitempty"` } // Event イベント情報 @@ -372,6 +375,9 @@ type GroupDetail struct { // GroupMember defines model for GroupMember. type GroupMember struct { + // DisplayName 表示名 + DisplayName string `json:"displayName"` + // Duration 班やプロジェクトの期間 // 年と前期/後期がある // untilがなかった場合存続中 @@ -438,6 +444,9 @@ type ProjectDetail struct { // ProjectMember defines model for ProjectMember. type ProjectMember struct { + // DisplayName 表示名 + DisplayName string `json:"displayName"` + // Duration 班やプロジェクトの期間 // 年と前期/後期がある // untilがなかった場合存続中 @@ -459,6 +468,9 @@ type Semester int32 // User ユーザー情報 type User struct { + // DisplayName 表示名 + DisplayName string `json:"displayName"` + // Id ユーザーUUID Id uuid.UUID `json:"id"` @@ -498,6 +510,9 @@ type UserDetail struct { // Bio 自己紹介(biography) Bio string `json:"bio"` + // DisplayName 表示名 + DisplayName string `json:"displayName"` + // Id ユーザーUUID Id uuid.UUID `json:"id"` diff --git a/internal/handler/user.go b/internal/handler/user.go index e5b73055..8ffb3c7b 100644 --- a/internal/handler/user.go +++ b/internal/handler/user.go @@ -42,7 +42,7 @@ func (h *UserHandler) GetUsers(c echo.Context) error { res := make([]schema.User, len(users)) for i, v := range users { - res[i] = newUser(v.ID, v.Name, v.RealName()) + res[i] = newUser(v.ID, v.Name, v.RealName(), v.DisplayName) } return c.JSON(http.StatusOK, res) @@ -77,7 +77,7 @@ func (h *UserHandler) GetUser(c echo.Context) error { } return c.JSON(http.StatusOK, newUserDetail( - newUser(user.ID, user.Name, user.RealName()), + newUser(user.ID, user.Name, user.RealName(), user.DisplayName), accounts, user.Bio, user.State, @@ -360,18 +360,19 @@ func (h *UserHandler) GetMe(c echo.Context) error { } return c.JSON(http.StatusOK, newUserDetail( - newUser(user.ID, user.Name, user.RealName()), + newUser(user.ID, user.Name, user.RealName(), user.User.DisplayName), accounts, user.Bio, user.State, )) } -func newUser(id uuid.UUID, name string, realName string) schema.User { +func newUser(id uuid.UUID, name string, realName string, displayName string) schema.User { return schema.User{ - Id: id, - Name: name, - RealName: realName, + Id: id, + Name: name, + RealName: realName, + DisplayName: displayName, } } diff --git a/internal/handler/user_test.go b/internal/handler/user_test.go index 0595f711..7862204f 100644 --- a/internal/handler/user_test.go +++ b/internal/handler/user_test.go @@ -46,7 +46,7 @@ func TestUserHandler_GetUsers(t *testing.T) { hresUsers := []*schema.User{} for range casenum { - ruser := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) + ruser := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) huser := schema.User{ Id: ruser.ID, Name: ruser.Name, @@ -72,7 +72,7 @@ func TestUserHandler_GetUsers(t *testing.T) { hresUsers := []*schema.User{} for range casenum { - ruser := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) + ruser := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) huser := schema.User{ Id: ruser.ID, Name: ruser.Name, @@ -97,7 +97,7 @@ func TestUserHandler_GetUsers(t *testing.T) { name: "Success_WithOpts_Name", setup: func(mr MockRepository) (hres []*schema.User, path string) { repoUsers := []*domain.User{ - domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), } hresUsers := []*schema.User{ { @@ -246,7 +246,7 @@ func TestUserHandler_GetUser(t *testing.T) { } repoUser := domain.UserDetail{ - User: *domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), + User: *domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()), State: rand.N(domain.TraqStateLimit), Bio: random.AlphaNumericN(rand.IntN(256) + 1), Accounts: rAccounts, @@ -1524,7 +1524,7 @@ func TestUserHandler_GetMe(t *testing.T) { userID := random.UUID() - ruser := domain.NewUser(userID, username, random.AlphaNumeric(), random.Bool()) + ruser := domain.NewUser(userID, username, random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) rusers := []*domain.User{ruser} mr.user.EXPECT().GetUsers(anyCtx{}, &repository.GetUsersArgs{ Name: optional.From(ruser.Name), diff --git a/internal/infrastructure/migration/v3.go b/internal/infrastructure/migration/v3.go index 805cc398..6de52748 100644 --- a/internal/infrastructure/migration/v3.go +++ b/internal/infrastructure/migration/v3.go @@ -2,7 +2,6 @@ package migration import ( - "database/sql" "github.com/traPtitech/traPortfolio/internal/domain" "time" @@ -33,7 +32,7 @@ type v3User struct { Description string `gorm:"type:text;not null"` Check bool `gorm:"type:boolean;not null;default:false"` Name string `gorm:"type:varchar(32);not null;unique"` - DisplayName sql.NullString `gorm:"type:varchar(32)"` // 追加 + DisplayName *string `gorm:"type:varchar(32)"` // 追加 State domain.TraQState `gorm:"type:tinyint(1);not null"` CreatedAt time.Time `gorm:"precision:6"` UpdatedAt time.Time `gorm:"precision:6"` diff --git a/internal/infrastructure/repository/contest_impl.go b/internal/infrastructure/repository/contest_impl.go index 6971ce4f..a0338d13 100644 --- a/internal/infrastructure/repository/contest_impl.go +++ b/internal/infrastructure/repository/contest_impl.go @@ -243,7 +243,7 @@ func (r *ContestRepository) GetContestTeams(ctx context.Context, contestID uuid. members := make([]*domain.User, len(belongingMap[v.ID])) for i, w := range belongingMap[v.ID] { u := w.User - members[i] = domain.NewUser(u.ID, u.Name, realNameMap[u.Name], u.Check) + members[i] = domain.NewUser(u.ID, u.Name, realNameMap[u.Name], u.DisplayName, u.Check) } result = append(result, &domain.ContestTeam{ @@ -294,7 +294,7 @@ func (r *ContestRepository) GetContestTeam(ctx context.Context, contestID uuid.U members := make([]*domain.User, len(belongings)) for i, w := range belongings { u := w.User - members[i] = domain.NewUser(u.ID, u.Name, realNameMap[u.Name], u.Check) + members[i] = domain.NewUser(u.ID, u.Name, realNameMap[u.Name], u.DisplayName, u.Check) } res := &domain.ContestTeamDetail{ @@ -470,7 +470,7 @@ func (r *ContestRepository) GetContestTeamMembers(ctx context.Context, contestID result := make([]*domain.User, len(belongings)) for i, v := range belongings { u := v.User - result[i] = domain.NewUser(u.ID, u.Name, realNameMap[u.Name], u.Check) + result[i] = domain.NewUser(u.ID, u.Name, realNameMap[u.Name], u.DisplayName, u.Check) } return result, nil } diff --git a/internal/infrastructure/repository/contest_test.go b/internal/infrastructure/repository/contest_test.go index d1285e65..4bcad257 100644 --- a/internal/infrastructure/repository/contest_test.go +++ b/internal/infrastructure/repository/contest_test.go @@ -365,8 +365,8 @@ func Test_GetContestTeamMembers(t *testing.T) { }) portalAPI.EXPECT().GetUsers().Return(portalUsers, nil) expectedMembers := []*domain.User{ - domain.NewUser(traqUsers[0].ID, traqUsers[0].Name, portalUsers[0].RealName, false), - domain.NewUser(traqUsers[1].ID, traqUsers[1].Name, portalUsers[1].RealName, false), + domain.NewUser(traqUsers[0].ID, traqUsers[0].Name, portalUsers[0].RealName, "", false), + domain.NewUser(traqUsers[1].ID, traqUsers[1].Name, portalUsers[1].RealName, "", false), } gotMembers, err := repo.GetContestTeamMembers(context.Background(), contest1.ID, team1.ID) assert.NoError(t, err) diff --git a/internal/infrastructure/repository/model/user.go b/internal/infrastructure/repository/model/user.go index 865c0538..6cd9ce61 100644 --- a/internal/infrastructure/repository/model/user.go +++ b/internal/infrastructure/repository/model/user.go @@ -1,7 +1,6 @@ package model import ( - "database/sql" "time" "github.com/gofrs/uuid" @@ -13,7 +12,7 @@ type User struct { Description string `gorm:"type:text;not null"` Check bool `gorm:"type:boolean;not null;default:false"` Name string `gorm:"type:varchar(32);not null;unique"` - DisplayName sql.NullString `gorm:"type:varchar(32)"` + DisplayName string `gorm:"type:varchar(32)"` State domain.TraQState `gorm:"type:tinyint(1);not null"` CreatedAt time.Time `gorm:"precision:6"` UpdatedAt time.Time `gorm:"precision:6"` diff --git a/internal/infrastructure/repository/project_impl.go b/internal/infrastructure/repository/project_impl.go index abd1ae8f..f7d08def 100644 --- a/internal/infrastructure/repository/project_impl.go +++ b/internal/infrastructure/repository/project_impl.go @@ -74,6 +74,7 @@ func (r *ProjectRepository) GetProject(ctx context.Context, projectID uuid.UUID) v.User.ID, v.User.Name, realNameMap[v.User.Name], + v.User.DisplayName, v.User.Check, ), Duration: domain.NewYearWithSemesterDuration(v.SinceYear, v.SinceSemester, v.UntilYear, v.UntilSemester), @@ -239,6 +240,7 @@ func (r *ProjectRepository) GetProjectMembers(ctx context.Context, projectID uui v.User.ID, v.User.Name, realNameMap[v.User.Name], + v.User.DisplayName, v.User.Check, ), Duration: domain.NewYearWithSemesterDuration(v.SinceYear, v.SinceSemester, v.UntilYear, v.UntilSemester), diff --git a/internal/infrastructure/repository/project_test.go b/internal/infrastructure/repository/project_test.go index 64e95179..65c6b5f2 100644 --- a/internal/infrastructure/repository/project_test.go +++ b/internal/infrastructure/repository/project_test.go @@ -205,12 +205,14 @@ func TestProjectRepository_GetProjectMembers(t *testing.T) { mockdata.MockUsers[0].ID, mockdata.MockUsers[0].Name, mockdata.MockPortalUsers[0].RealName, + mockdata.MockUsers[1].DisplayName, mockdata.MockUsers[0].Check, ) user2 := domain.NewUser( mockdata.MockUsers[1].ID, mockdata.MockUsers[1].Name, mockdata.MockPortalUsers[1].RealName, + mockdata.MockUsers[1].DisplayName, mockdata.MockUsers[1].Check, ) @@ -299,18 +301,21 @@ func TestProjectRepository_EditProjectMembers(t *testing.T) { mockdata.MockUsers[0].ID, mockdata.MockUsers[0].Name, mockdata.MockPortalUsers[0].RealName, + mockdata.MockUsers[1].DisplayName, mockdata.MockUsers[0].Check, ) user2 := domain.NewUser( mockdata.MockUsers[1].ID, mockdata.MockUsers[1].Name, mockdata.MockPortalUsers[1].RealName, + mockdata.MockUsers[1].DisplayName, mockdata.MockUsers[1].Check, ) user3 := domain.NewUser( mockdata.MockUsers[2].ID, mockdata.MockUsers[2].Name, mockdata.MockPortalUsers[2].RealName, + mockdata.MockUsers[2].DisplayName, mockdata.MockUsers[2].Check, ) diff --git a/internal/infrastructure/repository/user_impl.go b/internal/infrastructure/repository/user_impl.go index c5844e8f..7b8350df 100644 --- a/internal/infrastructure/repository/user_impl.go +++ b/internal/infrastructure/repository/user_impl.go @@ -60,6 +60,7 @@ func (r *UserRepository) GetUsers(ctx context.Context, args *repository.GetUsers users[0].ID, users[0].Name, portalUser.RealName, + users[0].DisplayName, users[0].Check, ), }, nil @@ -75,6 +76,7 @@ func (r *UserRepository) GetUsers(ctx context.Context, args *repository.GetUsers v.ID, v.Name, realNameMap[v.Name], + v.DisplayName, v.Check, )) } @@ -149,6 +151,7 @@ func (r *UserRepository) GetUser(ctx context.Context, userID uuid.UUID) (*domain user.ID, user.Name, portalUser.RealName, + user.DisplayName, user.Check, ), State: user.State, diff --git a/internal/infrastructure/repository/user_test.go b/internal/infrastructure/repository/user_test.go index 867c761d..8e73e4e7 100644 --- a/internal/infrastructure/repository/user_test.go +++ b/internal/infrastructure/repository/user_test.go @@ -40,12 +40,14 @@ func TestUserRepository_GetUsers(t *testing.T) { mockdata.MockTraQUsers[0].ID, mockdata.MockTraQUsers[0].Name, mockdata.MockPortalUsers[0].RealName, + mockdata.MockUsers[0].DisplayName, mockdata.MockUsers[0].Check, ), domain.NewUser( mockdata.MockTraQUsers[2].ID, mockdata.MockTraQUsers[2].Name, mockdata.MockPortalUsers[2].RealName, + mockdata.MockUsers[2].DisplayName, mockdata.MockUsers[2].Check, ), }, @@ -61,18 +63,21 @@ func TestUserRepository_GetUsers(t *testing.T) { mockdata.MockUsers[0].ID, mockdata.MockUsers[0].Name, mockdata.MockPortalUsers[0].RealName, + mockdata.MockUsers[0].DisplayName, mockdata.MockUsers[0].Check, ), domain.NewUser( mockdata.MockUsers[1].ID, mockdata.MockUsers[1].Name, mockdata.MockPortalUsers[1].RealName, + mockdata.MockUsers[1].DisplayName, mockdata.MockUsers[1].Check, ), domain.NewUser( mockdata.MockUsers[2].ID, mockdata.MockUsers[2].Name, mockdata.MockPortalUsers[2].RealName, + mockdata.MockUsers[2].DisplayName, mockdata.MockUsers[2].Check, ), }, @@ -88,6 +93,7 @@ func TestUserRepository_GetUsers(t *testing.T) { mockdata.MockUsers[0].ID, mockdata.MockUsers[0].Name, mockdata.MockPortalUsers[0].RealName, + mockdata.MockUsers[0].DisplayName, mockdata.MockUsers[0].Check, ), }, @@ -141,6 +147,7 @@ func TestUserRepository_GetUser(t *testing.T) { mockdata.MockUsers[2].ID, mockdata.MockUsers[2].Name, mockdata.MockPortalUsers[2].RealName, + mockdata.MockUsers[2].DisplayName, mockdata.MockUsers[2].Check, ), State: mockdata.MockTraQUsers[2].State, @@ -159,6 +166,7 @@ func TestUserRepository_GetUser(t *testing.T) { mockdata.MockUsers[0].ID, mockdata.MockUsers[0].Name, mockdata.MockPortalUsers[0].RealName, + mockdata.MockUsers[0].DisplayName, mockdata.MockUsers[0].Check, ), State: mockdata.MockTraQUsers[0].State, @@ -239,6 +247,7 @@ func TestUserRepository_UpdateUser(t *testing.T) { user.ID, user.Name, portalUser.RealName, + user.DisplayName, check, ), State: traqUser.State, diff --git a/internal/pkgs/mockdata/handler.go b/internal/pkgs/mockdata/handler.go index a1db9237..b040ef7a 100644 --- a/internal/pkgs/mockdata/handler.go +++ b/internal/pkgs/mockdata/handler.go @@ -361,7 +361,7 @@ func CloneHandlerMockUsers() []schema.User { ) for i, u := range mUsers { - d := *domain.NewUser(u.ID, u.Name, portalUsers[i].RealName, u.Check) + d := *domain.NewUser(u.ID, u.Name, portalUsers[i].RealName, u.DisplayName, u.Check) hUsers[i] = schema.User{ Id: d.ID, Name: d.Name, From bc020a4bf2dd629b53cc01bcd5a016d0ae57fcce Mon Sep 17 00:00:00 2001 From: ZOI-dayo Date: Thu, 26 Dec 2024 16:56:02 +0900 Subject: [PATCH 5/5] fix problems for unit test / Add comment to DB schema --- .tbls.yml | 1 + docs/dbschema/schema.json | 2 +- docs/dbschema/users.md | 2 +- internal/handler/contest.go | 7 ++-- internal/handler/contest_test.go | 32 +++++++++++-------- internal/handler/event_test.go | 7 ++-- internal/handler/group.go | 9 +++--- internal/handler/group_test.go | 16 ++++++---- internal/handler/user_test.go | 21 ++++++------ .../infrastructure/repository/group_impl.go | 3 +- internal/pkgs/mockdata/handler.go | 14 ++++---- 11 files changed, 65 insertions(+), 49 deletions(-) diff --git a/.tbls.yml b/.tbls.yml index 2aa934f5..45dc6d03 100644 --- a/.tbls.yml +++ b/.tbls.yml @@ -22,6 +22,7 @@ comments: description: 自己紹介文 check: "氏名を公開するかどうかの可否 (0: 停止, 1: 有効, 2: 一時停止)" name: ユーザー名 + display_name: ユーザー表示名 state: traQのユーザーアカウント状態 - table: event_level_relations tableComment: knoQイベントと公開レベルの関係テーブル diff --git a/docs/dbschema/schema.json b/docs/dbschema/schema.json index cd5d66f1..7c06b2aa 100644 --- a/docs/dbschema/schema.json +++ b/docs/dbschema/schema.json @@ -1 +1 @@ -{"name":"portfolio","desc":"","tables":[{"name":"accounts","type":"BASE TABLE","comment":"Twitterなどのアカウントテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"アカウントUUID"},{"name":"type","type":"tinyint(1)","nullable":false,"default":null,"comment":"アカウントのハードコードID"},{"name":"name","type":"varchar(256)","nullable":true,"default":"NULL","comment":"アカウント名"},{"name":"url","type":"text","nullable":true,"default":"NULL","comment":"アカウントのURL"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"公開可能かどうか"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_users_accounts","def":"KEY fk_users_accounts (user_id) USING BTREE","table":"accounts","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"accounts","columns":["id"],"comment":""}],"constraints":[{"name":"fk_users_accounts","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"accounts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"accounts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `accounts` (\n `id` char(36) NOT NULL,\n `type` tinyint(1) NOT NULL,\n `name` varchar(256) DEFAULT NULL,\n `url` text DEFAULT NULL,\n `user_id` char(36) NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_users_accounts` (`user_id`),\n CONSTRAINT `fk_users_accounts` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contests","type":"BASE TABLE","comment":"コンテストテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"コンテスト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"コンテスト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテスト情報のリンク"},{"name":"since","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間始まり"},{"name":"until","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間終わり"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contests","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contests","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contests` (\n `id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since` datetime(6) DEFAULT NULL,\n `until` datetime(6) DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_teams","type":"BASE TABLE","comment":"コンテスト参加チームテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"contest_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"チーム名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"チーム情報"},{"name":"result","type":"text","nullable":true,"default":"NULL","comment":"順位などの結果"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテストチームの詳細が載っているページへのリンク"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム更新日時"}],"indexes":[{"name":"fk_contest_teams_contest","def":"KEY fk_contest_teams_contest (contest_id) USING BTREE","table":"contest_teams","columns":["contest_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contest_teams","columns":["id"],"comment":""}],"constraints":[{"name":"fk_contest_teams_contest","type":"FOREIGN KEY","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","table":"contest_teams","referenced_table":"contests","columns":["contest_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contest_teams","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_teams` (\n `id` char(36) NOT NULL,\n `contest_id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `result` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_contest_teams_contest` (`contest_id`),\n CONSTRAINT `fk_contest_teams_contest` FOREIGN KEY (`contest_id`) REFERENCES `contests` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_team_user_belongings","type":"BASE TABLE","comment":"コンテストチームとユーザー関係テーブル","columns":[{"name":"team_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_contest_team_user_belongings_user","def":"KEY fk_contest_team_user_belongings_user (user_id) USING BTREE","table":"contest_team_user_belongings","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (team_id, user_id) USING BTREE","table":"contest_team_user_belongings","columns":["team_id","user_id"],"comment":""}],"constraints":[{"name":"fk_contest_team_user_belongings_contest_team","type":"FOREIGN KEY","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","table":"contest_team_user_belongings","referenced_table":"contest_teams","columns":["team_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_contest_team_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"contest_team_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (team_id, user_id)","table":"contest_team_user_belongings","referenced_table":null,"columns":["team_id","user_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_team_user_belongings` (\n `team_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`team_id`,`user_id`),\n KEY `fk_contest_team_user_belongings_user` (`user_id`),\n CONSTRAINT `fk_contest_team_user_belongings_contest_team` FOREIGN KEY (`team_id`) REFERENCES `contest_teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_contest_team_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"event_level_relations","type":"BASE TABLE","comment":"knoQイベントと公開レベルの関係テーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"knoQイベントUUID"},{"name":"level","type":"tinyint(3) unsigned","nullable":false,"default":"0","comment":"公開レベル。0なら匿名、1ならそのまま公開、2なら外部に非公開"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"event_level_relations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"event_level_relations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `event_level_relations` (\n `id` char(36) NOT NULL,\n `level` tinyint(3) unsigned NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"groups","type":"BASE TABLE","comment":"グループテーブル","columns":[{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"グループ名"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"グループのリンク"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"グループの説明文"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (group_id) USING BTREE","table":"groups","columns":["group_id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (group_id)","table":"groups","referenced_table":null,"columns":["group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `groups` (\n `group_id` char(36) NOT NULL,\n `name` varchar(32) DEFAULT NULL,\n `link` text DEFAULT NULL,\n `description` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`group_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_admins","type":"BASE TABLE","comment":"グループと管理者関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_admins_group","def":"KEY fk_group_user_admins_group (group_id) USING BTREE","table":"group_user_admins","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_admins","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_admins_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_admins","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_admins","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_admins` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_admins_group` (`group_id`),\n CONSTRAINT `fk_group_user_admins_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_belongings","type":"BASE TABLE","comment":"グループとユーザー関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_belongings_group","def":"KEY fk_group_user_belongings_group (group_id) USING BTREE","table":"group_user_belongings","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_belongings","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_belongings_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_belongings","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"fk_group_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"group_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_belongings","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_belongings` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_belongings_group` (`group_id`),\n CONSTRAINT `fk_group_user_belongings_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_group_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"migrations","type":"BASE TABLE","comment":"gormigrate用のデータベースバージョンテーブル","columns":[{"name":"id","type":"varchar(255)","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"migrations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"migrations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `migrations` (\n `id` varchar(255) NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"projects","type":"BASE TABLE","comment":"プロジェクトテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"プロジェクト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト情報のリンク"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"projects","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"projects","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `projects` (\n `id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"project_members","type":"BASE TABLE","comment":"プロジェクト所属者テーブル","columns":[{"name":"project_id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_project_members_user","def":"KEY fk_project_members_user (user_id) USING BTREE","table":"project_members","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (project_id, user_id) USING BTREE","table":"project_members","columns":["project_id","user_id"],"comment":""}],"constraints":[{"name":"fk_project_members_project","type":"FOREIGN KEY","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","table":"project_members","referenced_table":"projects","columns":["project_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_project_members_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"project_members","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (project_id, user_id)","table":"project_members","referenced_table":null,"columns":["project_id","user_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `project_members` (\n `project_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`project_id`,`user_id`),\n KEY `fk_project_members_user` (`user_id`),\n CONSTRAINT `fk_project_members_project` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_project_members_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"users","type":"BASE TABLE","comment":"ユーザーテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"description","type":"text","nullable":false,"default":null,"comment":"自己紹介文"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"氏名を公開するかどうかの可否 (0: 停止, 1: 有効, 2: 一時停止)"},{"name":"name","type":"varchar(32)","nullable":false,"default":null,"comment":"ユーザー名"},{"name":"display_name","type":"varchar(32)","nullable":true,"default":"NULL","comment":""},{"name":"state","type":"tinyint(1)","nullable":false,"default":null,"comment":"traQのユーザーアカウント状態"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"users","columns":["id"],"comment":""},{"name":"uni_users_name","def":"UNIQUE KEY uni_users_name (name) USING BTREE","table":"users","columns":["name"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"uni_users_name","type":"UNIQUE","def":"UNIQUE KEY uni_users_name (name)","table":"users","referenced_table":null,"columns":["name"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `users` (\n `id` char(36) NOT NULL,\n `description` text NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `name` varchar(32) NOT NULL,\n `display_name` varchar(32) DEFAULT NULL,\n `state` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `uni_users_name` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"}],"relations":[{"table":"accounts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"contest_teams","columns":["contest_id"],"cardinality":"Zero or more","parent_table":"contests","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["team_id"],"cardinality":"Zero or more","parent_table":"contest_teams","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"group_user_admins","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"project_members","columns":["project_id"],"cardinality":"Zero or more","parent_table":"projects","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","virtual":false},{"table":"project_members","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false}],"functions":[],"driver":{"name":"mariadb","database_version":"10.6.4-MariaDB-1:10.6.4+maria~focal","meta":{"dict":{"Functions":"Stored procedures and functions"}}}} +{"name":"portfolio","desc":"","tables":[{"name":"accounts","type":"BASE TABLE","comment":"Twitterなどのアカウントテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"アカウントUUID"},{"name":"type","type":"tinyint(1)","nullable":false,"default":null,"comment":"アカウントのハードコードID"},{"name":"name","type":"varchar(256)","nullable":true,"default":"NULL","comment":"アカウント名"},{"name":"url","type":"text","nullable":true,"default":"NULL","comment":"アカウントのURL"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"公開可能かどうか"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_users_accounts","def":"KEY fk_users_accounts (user_id) USING BTREE","table":"accounts","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"accounts","columns":["id"],"comment":""}],"constraints":[{"name":"fk_users_accounts","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"accounts","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"accounts","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `accounts` (\n `id` char(36) NOT NULL,\n `type` tinyint(1) NOT NULL,\n `name` varchar(256) DEFAULT NULL,\n `url` text DEFAULT NULL,\n `user_id` char(36) NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_users_accounts` (`user_id`),\n CONSTRAINT `fk_users_accounts` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contests","type":"BASE TABLE","comment":"コンテストテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"コンテスト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"コンテスト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテスト情報のリンク"},{"name":"since","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間始まり"},{"name":"until","type":"datetime(6)","nullable":true,"default":"NULL","comment":"期間終わり"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテスト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contests","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contests","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contests` (\n `id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since` datetime(6) DEFAULT NULL,\n `until` datetime(6) DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_teams","type":"BASE TABLE","comment":"コンテスト参加チームテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"contest_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"チーム名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"チーム情報"},{"name":"result","type":"text","nullable":true,"default":"NULL","comment":"順位などの結果"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"コンテストチームの詳細が載っているページへのリンク"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"コンテストチーム更新日時"}],"indexes":[{"name":"fk_contest_teams_contest","def":"KEY fk_contest_teams_contest (contest_id) USING BTREE","table":"contest_teams","columns":["contest_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"contest_teams","columns":["id"],"comment":""}],"constraints":[{"name":"fk_contest_teams_contest","type":"FOREIGN KEY","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","table":"contest_teams","referenced_table":"contests","columns":["contest_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"contest_teams","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_teams` (\n `id` char(36) NOT NULL,\n `contest_id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `result` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `fk_contest_teams_contest` (`contest_id`),\n CONSTRAINT `fk_contest_teams_contest` FOREIGN KEY (`contest_id`) REFERENCES `contests` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"contest_team_user_belongings","type":"BASE TABLE","comment":"コンテストチームとユーザー関係テーブル","columns":[{"name":"team_id","type":"char(36)","nullable":false,"default":null,"comment":"コンテストチームUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_contest_team_user_belongings_user","def":"KEY fk_contest_team_user_belongings_user (user_id) USING BTREE","table":"contest_team_user_belongings","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (team_id, user_id) USING BTREE","table":"contest_team_user_belongings","columns":["team_id","user_id"],"comment":""}],"constraints":[{"name":"fk_contest_team_user_belongings_contest_team","type":"FOREIGN KEY","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","table":"contest_team_user_belongings","referenced_table":"contest_teams","columns":["team_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_contest_team_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"contest_team_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (team_id, user_id)","table":"contest_team_user_belongings","referenced_table":null,"columns":["team_id","user_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `contest_team_user_belongings` (\n `team_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`team_id`,`user_id`),\n KEY `fk_contest_team_user_belongings_user` (`user_id`),\n CONSTRAINT `fk_contest_team_user_belongings_contest_team` FOREIGN KEY (`team_id`) REFERENCES `contest_teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_contest_team_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"event_level_relations","type":"BASE TABLE","comment":"knoQイベントと公開レベルの関係テーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"knoQイベントUUID"},{"name":"level","type":"tinyint(3) unsigned","nullable":false,"default":"0","comment":"公開レベル。0なら匿名、1ならそのまま公開、2なら外部に非公開"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"event_level_relations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"event_level_relations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `event_level_relations` (\n `id` char(36) NOT NULL,\n `level` tinyint(3) unsigned NOT NULL DEFAULT 0,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"groups","type":"BASE TABLE","comment":"グループテーブル","columns":[{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"グループ名"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"グループのリンク"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"グループの説明文"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"グループ更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (group_id) USING BTREE","table":"groups","columns":["group_id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (group_id)","table":"groups","referenced_table":null,"columns":["group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `groups` (\n `group_id` char(36) NOT NULL,\n `name` varchar(32) DEFAULT NULL,\n `link` text DEFAULT NULL,\n `description` text DEFAULT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`group_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_admins","type":"BASE TABLE","comment":"グループと管理者関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_admins_group","def":"KEY fk_group_user_admins_group (group_id) USING BTREE","table":"group_user_admins","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_admins","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_admins_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_admins","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_admins","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_admins` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_admins_group` (`group_id`),\n CONSTRAINT `fk_group_user_admins_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"group_user_belongings","type":"BASE TABLE","comment":"グループとユーザー関係テーブル","columns":[{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"group_id","type":"char(36)","nullable":false,"default":null,"comment":"グループUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"ユーザー所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"ユーザー所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"関係テーブル更新日時"}],"indexes":[{"name":"fk_group_user_belongings_group","def":"KEY fk_group_user_belongings_group (group_id) USING BTREE","table":"group_user_belongings","columns":["group_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (user_id, group_id) USING BTREE","table":"group_user_belongings","columns":["user_id","group_id"],"comment":""}],"constraints":[{"name":"fk_group_user_belongings_group","type":"FOREIGN KEY","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","table":"group_user_belongings","referenced_table":"groups","columns":["group_id"],"referenced_columns":["group_id"],"comment":""},{"name":"fk_group_user_belongings_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"group_user_belongings","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (user_id, group_id)","table":"group_user_belongings","referenced_table":null,"columns":["user_id","group_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `group_user_belongings` (\n `user_id` char(36) NOT NULL,\n `group_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`user_id`,`group_id`),\n KEY `fk_group_user_belongings_group` (`group_id`),\n CONSTRAINT `fk_group_user_belongings_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_group_user_belongings_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"migrations","type":"BASE TABLE","comment":"gormigrate用のデータベースバージョンテーブル","columns":[{"name":"id","type":"varchar(255)","nullable":false,"default":null,"comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"migrations","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"migrations","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `migrations` (\n `id` varchar(255) NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"projects","type":"BASE TABLE","comment":"プロジェクトテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"name","type":"varchar(128)","nullable":true,"default":"NULL","comment":"プロジェクト名"},{"name":"description","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト説明"},{"name":"link","type":"text","nullable":true,"default":"NULL","comment":"プロジェクト情報のリンク"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト作成日時"},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":"プロジェクト更新日時"}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"projects","columns":["id"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"projects","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `projects` (\n `id` char(36) NOT NULL,\n `name` varchar(128) DEFAULT NULL,\n `description` text DEFAULT NULL,\n `link` text DEFAULT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"project_members","type":"BASE TABLE","comment":"プロジェクト所属者テーブル","columns":[{"name":"project_id","type":"char(36)","nullable":false,"default":null,"comment":"プロジェクトUUID"},{"name":"user_id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"since_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属開始年"},{"name":"since_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属開始学期(0:前期 1:後期)"},{"name":"until_year","type":"smallint(4)","nullable":false,"default":null,"comment":"プロジェクト所属終了年"},{"name":"until_semester","type":"tinyint(1)","nullable":false,"default":null,"comment":"プロジェクト所属終了学期(0:前期 1:後期)"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"fk_project_members_user","def":"KEY fk_project_members_user (user_id) USING BTREE","table":"project_members","columns":["user_id"],"comment":""},{"name":"PRIMARY","def":"PRIMARY KEY (project_id, user_id) USING BTREE","table":"project_members","columns":["project_id","user_id"],"comment":""}],"constraints":[{"name":"fk_project_members_project","type":"FOREIGN KEY","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","table":"project_members","referenced_table":"projects","columns":["project_id"],"referenced_columns":["id"],"comment":""},{"name":"fk_project_members_user","type":"FOREIGN KEY","def":"FOREIGN KEY (user_id) REFERENCES users (id)","table":"project_members","referenced_table":"users","columns":["user_id"],"referenced_columns":["id"],"comment":""},{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (project_id, user_id)","table":"project_members","referenced_table":null,"columns":["project_id","user_id"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `project_members` (\n `project_id` char(36) NOT NULL,\n `user_id` char(36) NOT NULL,\n `since_year` smallint(4) NOT NULL,\n `since_semester` tinyint(1) NOT NULL,\n `until_year` smallint(4) NOT NULL,\n `until_semester` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`project_id`,`user_id`),\n KEY `fk_project_members_user` (`user_id`),\n CONSTRAINT `fk_project_members_project` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `fk_project_members_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"},{"name":"users","type":"BASE TABLE","comment":"ユーザーテーブル","columns":[{"name":"id","type":"char(36)","nullable":false,"default":null,"comment":"ユーザーUUID"},{"name":"description","type":"text","nullable":false,"default":null,"comment":"自己紹介文"},{"name":"check","type":"tinyint(1)","nullable":false,"default":"0","comment":"氏名を公開するかどうかの可否 (0: 停止, 1: 有効, 2: 一時停止)"},{"name":"name","type":"varchar(32)","nullable":false,"default":null,"comment":"ユーザー名"},{"name":"display_name","type":"varchar(32)","nullable":true,"default":"NULL","comment":"ユーザー表示名"},{"name":"state","type":"tinyint(1)","nullable":false,"default":null,"comment":"traQのユーザーアカウント状態"},{"name":"created_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""},{"name":"updated_at","type":"datetime(6)","nullable":true,"default":"NULL","comment":""}],"indexes":[{"name":"PRIMARY","def":"PRIMARY KEY (id) USING BTREE","table":"users","columns":["id"],"comment":""},{"name":"uni_users_name","def":"UNIQUE KEY uni_users_name (name) USING BTREE","table":"users","columns":["name"],"comment":""}],"constraints":[{"name":"PRIMARY","type":"PRIMARY KEY","def":"PRIMARY KEY (id)","table":"users","referenced_table":null,"columns":["id"],"referenced_columns":null,"comment":""},{"name":"uni_users_name","type":"UNIQUE","def":"UNIQUE KEY uni_users_name (name)","table":"users","referenced_table":null,"columns":["name"],"referenced_columns":null,"comment":""}],"triggers":[],"def":"CREATE TABLE `users` (\n `id` char(36) NOT NULL,\n `description` text NOT NULL,\n `check` tinyint(1) NOT NULL DEFAULT 0,\n `name` varchar(32) NOT NULL,\n `display_name` varchar(32) DEFAULT NULL,\n `state` tinyint(1) NOT NULL,\n `created_at` datetime(6) DEFAULT NULL,\n `updated_at` datetime(6) DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `uni_users_name` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"}],"relations":[{"table":"accounts","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"contest_teams","columns":["contest_id"],"cardinality":"Zero or more","parent_table":"contests","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (contest_id) REFERENCES contests (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["team_id"],"cardinality":"Zero or more","parent_table":"contest_teams","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (team_id) REFERENCES contest_teams (id)","virtual":false},{"table":"contest_team_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"group_user_admins","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["group_id"],"cardinality":"Zero or more","parent_table":"groups","parent_columns":["group_id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (group_id) REFERENCES groups (group_id)","virtual":false},{"table":"group_user_belongings","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false},{"table":"project_members","columns":["project_id"],"cardinality":"Zero or more","parent_table":"projects","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (project_id) REFERENCES projects (id)","virtual":false},{"table":"project_members","columns":["user_id"],"cardinality":"Zero or more","parent_table":"users","parent_columns":["id"],"parent_cardinality":"Exactly one","def":"FOREIGN KEY (user_id) REFERENCES users (id)","virtual":false}],"functions":[],"driver":{"name":"mariadb","database_version":"10.6.4-MariaDB-1:10.6.4+maria~focal","meta":{"dict":{"Functions":"Stored procedures and functions"}}}} diff --git a/docs/dbschema/users.md b/docs/dbschema/users.md index 07adeafc..f890d0b6 100644 --- a/docs/dbschema/users.md +++ b/docs/dbschema/users.md @@ -32,7 +32,7 @@ CREATE TABLE `users` ( | description | text | | false | | | 自己紹介文 | | check | tinyint(1) | 0 | false | | | 氏名を公開するかどうかの可否 (0: 停止, 1: 有効, 2: 一時停止) | | name | varchar(32) | | false | | | ユーザー名 | -| display_name | varchar(32) | NULL | true | | | | +| display_name | varchar(32) | NULL | true | | | ユーザー表示名 | | state | tinyint(1) | | false | | | traQのユーザーアカウント状態 | | created_at | datetime(6) | NULL | true | | | | | updated_at | datetime(6) | NULL | true | | | | diff --git a/internal/handler/contest.go b/internal/handler/contest.go index 74e9f89a..7ead7294 100644 --- a/internal/handler/contest.go +++ b/internal/handler/contest.go @@ -321,9 +321,10 @@ func (h *ContestHandler) GetContestTeamMembers(c echo.Context) error { res := make([]*schema.User, 0, len(users)) for _, v := range users { res = append(res, &schema.User{ - Id: v.ID, - Name: v.Name, - RealName: v.RealName(), + DisplayName: v.DisplayName, + Id: v.ID, + Name: v.Name, + RealName: v.RealName(), }) } return c.JSON(http.StatusOK, res) diff --git a/internal/handler/contest_test.go b/internal/handler/contest_test.go index e8c75cb6..afccc4df 100644 --- a/internal/handler/contest_test.go +++ b/internal/handler/contest_test.go @@ -156,9 +156,10 @@ func makeContest(t *testing.T) (*domain.ContestDetail, *schema.ContestDetail) { member := make([]schema.User, len(v.Members)) for j, w := range v.Members { member[j] = schema.User{ - Id: w.ID, - Name: w.Name, - RealName: w.RealName(), + DisplayName: w.DisplayName, + Id: w.ID, + Name: w.Name, + RealName: w.RealName(), } } teams[i] = schema.ContestTeam{ @@ -559,8 +560,8 @@ func TestContestHandler_GetContestTeams(t *testing.T) { { Id: repoContestTeams[0].ID, Members: []schema.User{ - {Id: repoContestTeams[0].Members[0].ID, Name: repoContestTeams[0].Members[0].Name, RealName: repoContestTeams[0].Members[0].RealName()}, - {Id: repoContestTeams[0].Members[1].ID, Name: repoContestTeams[0].Members[1].Name, RealName: repoContestTeams[0].Members[1].RealName()}, + {Id: repoContestTeams[0].Members[0].ID, Name: repoContestTeams[0].Members[0].Name, RealName: repoContestTeams[0].Members[0].RealName(), DisplayName: repoContestTeams[0].Members[0].DisplayName}, + {Id: repoContestTeams[0].Members[1].ID, Name: repoContestTeams[0].Members[1].Name, RealName: repoContestTeams[0].Members[1].RealName(), DisplayName: repoContestTeams[0].Members[1].DisplayName}, }, Name: repoContestTeams[0].Name, Result: repoContestTeams[0].Result, @@ -568,8 +569,8 @@ func TestContestHandler_GetContestTeams(t *testing.T) { { Id: repoContestTeams[1].ID, Members: []schema.User{ - {Id: repoContestTeams[1].Members[0].ID, Name: repoContestTeams[1].Members[0].Name, RealName: repoContestTeams[1].Members[0].RealName()}, - {Id: repoContestTeams[1].Members[1].ID, Name: repoContestTeams[1].Members[1].Name, RealName: repoContestTeams[1].Members[1].RealName()}, + {Id: repoContestTeams[1].Members[0].ID, Name: repoContestTeams[1].Members[0].Name, RealName: repoContestTeams[1].Members[0].RealName(), DisplayName: repoContestTeams[1].Members[0].DisplayName}, + {Id: repoContestTeams[1].Members[1].ID, Name: repoContestTeams[1].Members[1].Name, RealName: repoContestTeams[1].Members[1].RealName(), DisplayName: repoContestTeams[1].Members[1].DisplayName}, }, Name: repoContestTeams[1].Name, Result: repoContestTeams[1].Result, @@ -637,9 +638,10 @@ func TestContestHandler_GetContestTeam(t *testing.T) { members := make([]schema.User, 0, len(repoContestTeamDetail.Members)) for _, member := range repoContestTeamDetail.Members { members = append(members, schema.User{ - Id: member.ID, - Name: member.Name, - RealName: member.RealName(), + DisplayName: member.DisplayName, + Id: member.ID, + Name: member.Name, + RealName: member.RealName(), }) } @@ -725,7 +727,8 @@ func TestContestHandler_AddContestTeam(t *testing.T) { Description: reqBody.Description, } want := domain.ContestTeamDetail{ - ContestTeam: domain.ContestTeam{ + ContestTeam: domain. + ContestTeam{ ContestTeamWithoutMembers: domain.ContestTeamWithoutMembers{ ID: teamID, ContestID: contestID, @@ -1037,9 +1040,10 @@ func TestContestHandler_GetContestTeamMembers(t *testing.T) { hres := make([]*schema.User, len(users)) for i, user := range users { hres[i] = &schema.User{ - Id: user.ID, - Name: user.Name, - RealName: user.RealName(), + DisplayName: user.DisplayName, + Id: user.ID, + Name: user.Name, + RealName: user.RealName(), } } diff --git a/internal/handler/event_test.go b/internal/handler/event_test.go index 74c609d0..e0ecbd03 100644 --- a/internal/handler/event_test.go +++ b/internal/handler/event_test.go @@ -112,9 +112,10 @@ func TestEventHandler_GetEvent(t *testing.T) { for range hostnum { rhost := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) hhost := schema.User{ - Id: rhost.ID, - Name: rhost.Name, - RealName: rhost.RealName(), + DisplayName: rhost.DisplayName, + Id: rhost.ID, + Name: rhost.Name, + RealName: rhost.RealName(), } rHost = append(rHost, rhost) diff --git a/internal/handler/group.go b/internal/handler/group.go index f45db5d1..6657ccba 100644 --- a/internal/handler/group.go +++ b/internal/handler/group.go @@ -107,10 +107,11 @@ func formatGetGroup(group *domain.GroupDetail) schema.GroupDetail { func newGroupMember(user schema.User, Duration schema.YearWithSemesterDuration) schema.GroupMember { return schema.GroupMember{ - Duration: Duration, - Id: user.Id, - Name: user.Name, - RealName: user.RealName, + DisplayName: user.DisplayName, + Duration: Duration, + Id: user.Id, + Name: user.Name, + RealName: user.RealName, } } diff --git a/internal/handler/group_test.go b/internal/handler/group_test.go index b469587c..0376de9a 100644 --- a/internal/handler/group_test.go +++ b/internal/handler/group_test.go @@ -109,9 +109,10 @@ func TestGroupHandler_GetGroup(t *testing.T) { rgroupAdmin := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) hgroupAdmin := schema.User{ - Id: rgroupAdmin.ID, - Name: rgroupAdmin.Name, - RealName: rgroupAdmin.RealName(), + DisplayName: rgroupAdmin.DisplayName, + Id: rgroupAdmin.ID, + Name: rgroupAdmin.Name, + RealName: rgroupAdmin.RealName(), } rgroupAdmins = append(rgroupAdmins, rgroupAdmin) @@ -129,10 +130,11 @@ func TestGroupHandler_GetGroup(t *testing.T) { } hgroupmember := schema.GroupMember{ - Duration: schema.ConvertDuration(rgroupmember.Duration), - Id: rgroupmember.User.ID, - Name: rgroupmember.User.Name, - RealName: rgroupmember.User.RealName(), + DisplayName: rgroupmember.User.DisplayName, + Duration: schema.ConvertDuration(rgroupmember.Duration), + Id: rgroupmember.User.ID, + Name: rgroupmember.User.Name, + RealName: rgroupmember.User.RealName(), } rgroupMembers = append(rgroupMembers, &rgroupmember) diff --git a/internal/handler/user_test.go b/internal/handler/user_test.go index 7862204f..a743c506 100644 --- a/internal/handler/user_test.go +++ b/internal/handler/user_test.go @@ -48,9 +48,10 @@ func TestUserHandler_GetUsers(t *testing.T) { for range casenum { ruser := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) huser := schema.User{ - Id: ruser.ID, - Name: ruser.Name, - RealName: ruser.RealName(), + DisplayName: ruser.DisplayName, + Id: ruser.ID, + Name: ruser.Name, + RealName: ruser.RealName(), } repoUsers = append(repoUsers, ruser) @@ -74,9 +75,10 @@ func TestUserHandler_GetUsers(t *testing.T) { for range casenum { ruser := domain.NewUser(random.UUID(), random.AlphaNumeric(), random.AlphaNumeric(), random.AlphaNumeric(), random.Bool()) huser := schema.User{ - Id: ruser.ID, - Name: ruser.Name, - RealName: ruser.RealName(), + DisplayName: ruser.DisplayName, + Id: ruser.ID, + Name: ruser.Name, + RealName: ruser.RealName(), } repoUsers = append(repoUsers, ruser) @@ -101,9 +103,10 @@ func TestUserHandler_GetUsers(t *testing.T) { } hresUsers := []*schema.User{ { - Id: repoUsers[0].ID, - Name: repoUsers[0].Name, - RealName: repoUsers[0].RealName(), + DisplayName: repoUsers[0].DisplayName, + Id: repoUsers[0].ID, + Name: repoUsers[0].Name, + RealName: repoUsers[0].RealName(), }, } diff --git a/internal/infrastructure/repository/group_impl.go b/internal/infrastructure/repository/group_impl.go index 09cd88c9..8bf2c689 100644 --- a/internal/infrastructure/repository/group_impl.go +++ b/internal/infrastructure/repository/group_impl.go @@ -59,7 +59,8 @@ func (r *GroupRepository) GetGroup(ctx context.Context, groupID uuid.UUID) (*dom for _, v := range users { erMembers = append(erMembers, &domain.UserWithDuration{ User: domain.User{ - ID: v.UserID, + DisplayName: v.User.DisplayName, + ID: v.UserID, // Name: v.Name, // RealName: v.RealName, }, diff --git a/internal/pkgs/mockdata/handler.go b/internal/pkgs/mockdata/handler.go index b040ef7a..5e55089f 100644 --- a/internal/pkgs/mockdata/handler.go +++ b/internal/pkgs/mockdata/handler.go @@ -121,9 +121,10 @@ func CloneHandlerMockContestTeamMembersByID() map[uuid.UUID][]schema.User { for i, cm := range mockMembers { if ct.UserID == cm.ID { hContestMembers[ct.TeamID] = append(hContestMembers[c.ID], schema.User{ - Id: cm.ID, - Name: cm.Name, - RealName: portalUsers[i].RealName, + DisplayName: cm.DisplayName, + Id: cm.ID, + Name: cm.Name, + RealName: portalUsers[i].RealName, }) } } @@ -363,9 +364,10 @@ func CloneHandlerMockUsers() []schema.User { for i, u := range mUsers { d := *domain.NewUser(u.ID, u.Name, portalUsers[i].RealName, u.DisplayName, u.Check) hUsers[i] = schema.User{ - Id: d.ID, - Name: d.Name, - RealName: d.RealName(), + DisplayName: d.DisplayName, + Id: d.ID, + Name: d.Name, + RealName: d.RealName(), } }