From 057cf185c83379c270ba3a831cf1c907d526781a Mon Sep 17 00:00:00 2001 From: Tennessine699 Date: Sat, 14 Dec 2024 22:21:24 +0900 Subject: [PATCH 1/3] clean: remove pr-permitted from user account --- .tbls.yml | 1 - docs/swagger/traPortfolio.v1.yaml | 12 ------ integration_tests/handler/user_test.go | 19 --------- internal/domain/user.go | 1 - internal/handler/schema/schema_gen.go | 14 +------ internal/handler/schema/validator.go | 2 - internal/handler/user.go | 15 +++---- internal/handler/user_test.go | 32 --------------- .../external/mock_external/mock_knoq.go | 1 + .../external/mock_external/mock_portal.go | 1 + .../external/mock_external/mock_traq.go | 1 + internal/infrastructure/migration/current.go | 1 + internal/infrastructure/migration/v3.go | 41 +++++++++++++++++++ .../infrastructure/repository/main_test.go | 1 - .../infrastructure/repository/model/user.go | 1 - .../infrastructure/repository/user_impl.go | 8 ---- .../infrastructure/repository/user_test.go | 11 ----- internal/pkgs/mockdata/handler.go | 1 - internal/pkgs/mockdata/model.go | 1 - internal/pkgs/random/repository.go | 2 - .../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 + .../usecases/repository/user_repository.go | 2 - 26 files changed, 83 insertions(+), 118 deletions(-) create mode 100644 internal/infrastructure/migration/v3.go diff --git a/.tbls.yml b/.tbls.yml index 2aa934f5..7d12585f 100644 --- a/.tbls.yml +++ b/.tbls.yml @@ -69,7 +69,6 @@ comments: name: アカウント名 url: アカウントのURL user_id: ユーザーUUID - check: 公開可能かどうか - table: projects tableComment: プロジェクトテーブル columnComments: diff --git a/docs/swagger/traPortfolio.v1.yaml b/docs/swagger/traPortfolio.v1.yaml index d8457692..acebb032 100644 --- a/docs/swagger/traPortfolio.v1.yaml +++ b/docs/swagger/traPortfolio.v1.yaml @@ -830,8 +830,6 @@ components: description: 外部アカウントの表示名 type: $ref: "#/components/schemas/AccountType" - prPermitted: - $ref: "#/components/schemas/PrPermitted" url: type: string description: アカウントurl @@ -839,7 +837,6 @@ components: - id - displayName - type - - prPermitted - url AccountType: type: integer @@ -1207,10 +1204,6 @@ components: required: - link - description - PrPermitted: - title: PrPermitted - type: boolean - description: 広報での利用が許可されているかどうか Duration: title: Duration type: object @@ -1306,8 +1299,6 @@ components: properties: type: $ref: "#/components/schemas/AccountType" - prPermitted: - $ref: "#/components/schemas/PrPermitted" url: type: string description: アカウントurl @@ -1317,7 +1308,6 @@ components: description: 外部アカウントの表示名 required: - type - - prPermitted - url - displayName EditUserAccountRequest: @@ -1327,8 +1317,6 @@ components: properties: type: $ref: "#/components/schemas/AccountType" - prPermitted: - $ref: "#/components/schemas/PrPermitted" url: type: string description: アカウントurl diff --git a/integration_tests/handler/user_test.go b/integration_tests/handler/user_test.go index 040c0520..09b3a7a4 100644 --- a/integration_tests/handler/user_test.go +++ b/integration_tests/handler/user_test.go @@ -327,7 +327,6 @@ func TestAddUserAccount(t *testing.T) { displayName = random.AlphaNumeric() justCountDisplayName = strings.Repeat("亜", 256) tooLongDisplayName = strings.Repeat("亜", 257) - prPermitted = schema.PrPermitted(random.Bool()) testUserID = mockdata.UserID1() accountType = schema.AccountType(mockdata.AccountTypesMockUserDoesntHave(testUserID)[0]) accountURL = random.AccountURLString(domain.AccountType(accountType)) @@ -349,14 +348,12 @@ func TestAddUserAccount(t *testing.T) { testUserID, schema.AddAccountRequest{ DisplayName: displayName, - PrPermitted: prPermitted, Type: accountType, Url: accountURL, }, schema.Account{ Id: uuid.Nil, DisplayName: displayName, - PrPermitted: prPermitted, Type: accountType, Url: accountURL, }, @@ -366,14 +363,12 @@ func TestAddUserAccount(t *testing.T) { testUserID2, schema.AddAccountRequest{ DisplayName: justCountDisplayName, - PrPermitted: prPermitted, Type: accountType2, Url: accountURL2, }, schema.Account{ Id: uuid.Nil, DisplayName: justCountDisplayName, - PrPermitted: prPermitted, Type: accountType2, Url: accountURL2, }, @@ -389,7 +384,6 @@ func TestAddUserAccount(t *testing.T) { testUserID, schema.AddAccountRequest{ DisplayName: displayName, - PrPermitted: prPermitted, Type: accountType, Url: "invalid url", }, @@ -400,7 +394,6 @@ func TestAddUserAccount(t *testing.T) { testUserID, schema.AddAccountRequest{ DisplayName: displayName, - PrPermitted: prPermitted, Type: schema.AccountType(domain.AccountLimit), Url: accountURL, }, @@ -411,7 +404,6 @@ func TestAddUserAccount(t *testing.T) { testUserID, schema.AddAccountRequest{ DisplayName: displayName, - PrPermitted: prPermitted, Type: conflictType, Url: random.AccountURLString(domain.AccountType(conflictType)), }, @@ -422,7 +414,6 @@ func TestAddUserAccount(t *testing.T) { testUserID, schema.AddAccountRequest{ DisplayName: tooLongDisplayName, - PrPermitted: prPermitted, Type: accountType, Url: accountURL, }, @@ -450,7 +441,6 @@ func TestAddUserAccount(t *testing.T) { func TestEditUserAccount(t *testing.T) { var ( displayName = random.AlphaNumeric() - prPermitted = schema.PrPermitted(random.Bool()) testAccount = mockdata.UserID1() accountType = schema.AccountType(mockdata.AccountTypesMockUserHas(testAccount)[0]) accountURL = random.AccountURLString(domain.AccountType(accountType)) @@ -474,7 +464,6 @@ func TestEditUserAccount(t *testing.T) { mockdata.AccountID1(), schema.EditUserAccountRequest{ DisplayName: &displayName, - PrPermitted: &prPermitted, Type: &accountType, Url: &accountURL, }, @@ -551,7 +540,6 @@ func TestEditUserAccount(t *testing.T) { mockdata.AccountID1(), schema.EditUserAccountRequest{ DisplayName: &displayName, - PrPermitted: &prPermitted, Type: &accountType, Url: &accountURL, }, @@ -570,13 +558,11 @@ func TestEditUserAccount(t *testing.T) { // Insert & Assert account = schema.Account{ DisplayName: random.AlphaNumeric(), - PrPermitted: schema.PrPermitted(random.Bool()), Type: schema.AccountType(initialAccountType), Url: random.AccountURLString(initialAccountType), } res := doRequest(t, e, http.MethodPost, e.URL(api.User.AddUserAccount, tt.userID), schema.AddAccountRequest{ DisplayName: account.DisplayName, - PrPermitted: account.PrPermitted, Type: account.Type, Url: account.Url, }) @@ -595,9 +581,6 @@ func TestEditUserAccount(t *testing.T) { if tt.reqBody.DisplayName != nil { account.DisplayName = *tt.reqBody.DisplayName } - if tt.reqBody.PrPermitted != nil { - account.PrPermitted = *tt.reqBody.PrPermitted - } if tt.reqBody.Type != nil { account.Type = *tt.reqBody.Type } @@ -660,14 +643,12 @@ func TestDeleteUserAccount(t *testing.T) { accountType := mockdata.AccountTypesMockUserDoesntHave(tt.userID)[0] reqBody := schema.AddAccountRequest{ DisplayName: random.AlphaNumeric(), - PrPermitted: schema.PrPermitted(random.Bool()), Type: accountType, Url: random.AccountURLString(domain.AccountType(accountType)), } res := doRequest(t, e, http.MethodPost, e.URL(api.User.AddUserAccount, tt.userID), &reqBody) assertResponse(t, http.StatusCreated, schema.Account{ DisplayName: reqBody.DisplayName, - PrPermitted: reqBody.PrPermitted, Type: reqBody.Type, Url: reqBody.Url, }, res, optSyncID, optRetrieveID(&tt.accountID)) diff --git a/internal/domain/user.go b/internal/domain/user.go index cdb95968..fdf522d7 100644 --- a/internal/domain/user.go +++ b/internal/domain/user.go @@ -44,7 +44,6 @@ type Account struct { ID uuid.UUID DisplayName string Type AccountType - PrPermitted bool URL string } diff --git a/internal/handler/schema/schema_gen.go b/internal/handler/schema/schema_gen.go index 742bee89..04283fd6 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 ( @@ -30,9 +30,6 @@ type Account struct { // Id アカウントUUID Id uuid.UUID `json:"id"` - // PrPermitted 広報での利用が許可されているかどうか - PrPermitted PrPermitted `json:"prPermitted"` - // Type アカウントの種類 Type AccountType `json:"type"` @@ -48,9 +45,6 @@ type AddAccountRequest struct { // DisplayName 外部アカウントの表示名 DisplayName string `json:"displayName"` - // PrPermitted 広報での利用が許可されているかどうか - PrPermitted PrPermitted `json:"prPermitted"` - // Type アカウントの種類 Type AccountType `json:"type"` @@ -268,9 +262,6 @@ type EditUserAccountRequest struct { // DisplayName 外部アカウントの表示名 DisplayName *string `json:"displayName,omitempty"` - // PrPermitted 広報での利用が許可されているかどうか - PrPermitted *PrPermitted `json:"prPermitted,omitempty"` - // Type アカウントの種類 Type *AccountType `json:"type,omitempty"` @@ -396,9 +387,6 @@ type MemberIDWithYearWithSemesterDuration struct { UserId uuid.UUID `json:"userId"` } -// PrPermitted 広報での利用が許可されているかどうか -type PrPermitted = bool - // Project プロジェクト情報 type Project struct { // Duration 班やプロジェクトの期間 diff --git a/internal/handler/schema/validator.go b/internal/handler/schema/validator.go index b50497cc..2a660558 100644 --- a/internal/handler/schema/validator.go +++ b/internal/handler/schema/validator.go @@ -36,7 +36,6 @@ func (p GetUsersParams) Validate() error { func (r AddAccountRequest) Validate() error { return vd.ValidateStruct(&r, vd.Field(&r.DisplayName, vd.Required, vdRuleDisplayNameLength), - vd.Field(&r.PrPermitted), vd.Field(&r.Type, vdRuleAccountTypeMax), vd.Field(&r.Url, vd.Required, is.URL), ) @@ -78,7 +77,6 @@ func (r CreateProjectRequest) Validate() error { func (r EditUserAccountRequest) Validate() error { return vd.ValidateStruct(&r, vd.Field(&r.DisplayName, vd.NilOrNotEmpty, vdRuleDisplayNameLength), - vd.Field(&r.PrPermitted), vd.Field(&r.Type, vdRuleAccountTypeMax), vd.Field(&r.Url, vd.NilOrNotEmpty, is.URL), ) diff --git a/internal/handler/user.go b/internal/handler/user.go index e5b73055..f94af9e3 100644 --- a/internal/handler/user.go +++ b/internal/handler/user.go @@ -73,7 +73,7 @@ func (h *UserHandler) GetUser(c echo.Context) error { accounts := make([]schema.Account, len(user.Accounts)) for i, v := range user.Accounts { - accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted) + accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL) } return c.JSON(http.StatusOK, newUserDetail( @@ -123,7 +123,7 @@ func (h *UserHandler) GetUserAccounts(c echo.Context) error { res := make([]schema.Account, len(accounts)) for i, v := range accounts { - res[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted) + res[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL) } return c.JSON(http.StatusOK, res) @@ -147,7 +147,7 @@ func (h *UserHandler) GetUserAccount(c echo.Context) error { return err } - return c.JSON(http.StatusOK, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL, account.PrPermitted)) + return c.JSON(http.StatusOK, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL)) } // AddUserAccount POST /users/:userID/accounts @@ -166,7 +166,6 @@ func (h *UserHandler) AddUserAccount(c echo.Context) error { args := repository.CreateAccountArgs{ DisplayName: req.DisplayName, Type: domain.AccountType(req.Type), - PrPermitted: bool(req.PrPermitted), URL: req.Url, } account, err := h.user.CreateAccount(ctx, userID, &args) @@ -174,7 +173,7 @@ func (h *UserHandler) AddUserAccount(c echo.Context) error { return err } - return c.JSON(http.StatusCreated, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL, account.PrPermitted)) + return c.JSON(http.StatusCreated, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL)) } // EditUserAccount PATCH /users/:userID/accounts/:accountID @@ -200,7 +199,6 @@ func (h *UserHandler) EditUserAccount(c echo.Context) error { DisplayName: optional.FromPtr(req.DisplayName), Type: optional.FromPtr((*domain.AccountType)(req.Type)), URL: optional.FromPtr(req.Url), - PrPermitted: optional.FromPtr(req.PrPermitted), } err = h.user.UpdateAccount(ctx, userID, accountID, &args) @@ -356,7 +354,7 @@ func (h *UserHandler) GetMe(c echo.Context) error { accounts := make([]schema.Account, len(user.Accounts)) for i, v := range user.Accounts { - accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted) + accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL) } return c.JSON(http.StatusOK, newUserDetail( @@ -386,13 +384,12 @@ func newUserDetail(user schema.User, accounts []schema.Account, bio string, stat } } -func newAccount(id uuid.UUID, displayName string, atype schema.AccountType, url string, prPermitted bool) schema.Account { +func newAccount(id uuid.UUID, displayName string, atype schema.AccountType, url string) schema.Account { return schema.Account{ Id: id, DisplayName: displayName, Type: atype, Url: url, - PrPermitted: schema.PrPermitted(prPermitted), } } diff --git a/internal/handler/user_test.go b/internal/handler/user_test.go index 0595f711..d5d7c164 100644 --- a/internal/handler/user_test.go +++ b/internal/handler/user_test.go @@ -223,20 +223,16 @@ func TestUserHandler_GetUser(t *testing.T) { hAccounts := []schema.Account{} for range accountNum { - prRandom := random.Bool() - raccount := domain.Account{ ID: random.UUID(), DisplayName: random.AlphaNumeric(), Type: rand.N(domain.AccountLimit), - PrPermitted: prRandom, URL: random.AlphaNumeric(), } haccount := schema.Account{ Id: raccount.ID, DisplayName: raccount.DisplayName, - PrPermitted: schema.PrPermitted(prRandom), Type: schema.AccountType(raccount.Type), Url: raccount.URL, } @@ -481,19 +477,16 @@ func TestUserHandler_GetUserAccounts(t *testing.T) { continue } - prRandom := random.Bool() raccount := domain.Account{ ID: random.UUID(), DisplayName: random.AlphaNumeric(), Type: domain.AccountType(uint8(i)), - PrPermitted: prRandom, URL: random.AlphaNumeric(), } haccount := schema.Account{ Id: raccount.ID, DisplayName: raccount.DisplayName, - PrPermitted: schema.PrPermitted(prRandom), Type: schema.AccountType(raccount.Type), Url: raccount.URL, } @@ -568,19 +561,16 @@ func TestUserHandler_GetUserAccount(t *testing.T) { name: "success", setup: func(mr MockRepository) (hres *schema.Account, path string) { userID := random.UUID() - prRandom := random.Bool() rAccount := domain.Account{ ID: random.UUID(), DisplayName: random.AlphaNumeric(), Type: rand.N(domain.AccountLimit), - PrPermitted: prRandom, URL: random.AlphaNumeric(), } hAccount := schema.Account{ Id: rAccount.ID, DisplayName: rAccount.DisplayName, - PrPermitted: schema.PrPermitted(prRandom), Type: schema.AccountType(rAccount.Type), Url: rAccount.URL, } @@ -660,7 +650,6 @@ func TestUserHandler_AddUserAccount(t *testing.T) { reqBody := schema.AddAccountRequest{ DisplayName: random.AlphaNumeric(), - PrPermitted: schema.PrPermitted(random.Bool()), Type: schema.AccountType(accountType), Url: random.AccountURLString(accountType), } @@ -669,21 +658,18 @@ func TestUserHandler_AddUserAccount(t *testing.T) { DisplayName: reqBody.DisplayName, Type: domain.AccountType(uint8(reqBody.Type)), URL: reqBody.Url, - PrPermitted: bool(reqBody.PrPermitted), } want := domain.Account{ ID: userID, DisplayName: args.DisplayName, Type: args.Type, - PrPermitted: args.PrPermitted, URL: args.URL, } expectedResBody := schema.Account{ Id: userID, DisplayName: reqBody.DisplayName, - PrPermitted: reqBody.PrPermitted, Type: reqBody.Type, Url: reqBody.Url, } @@ -701,7 +687,6 @@ func TestUserHandler_AddUserAccount(t *testing.T) { reqBody := schema.AddAccountRequest{ DisplayName: random.AlphaNumeric(), - PrPermitted: schema.PrPermitted(random.Bool()), Type: 0, Url: random.AccountURLString(0), } @@ -710,21 +695,18 @@ func TestUserHandler_AddUserAccount(t *testing.T) { DisplayName: reqBody.DisplayName, Type: domain.AccountType(uint8(reqBody.Type)), URL: reqBody.Url, - PrPermitted: bool(reqBody.PrPermitted), } want := domain.Account{ ID: userID, DisplayName: args.DisplayName, Type: args.Type, - PrPermitted: args.PrPermitted, URL: args.URL, } expectedResBody := schema.Account{ Id: userID, DisplayName: reqBody.DisplayName, - PrPermitted: reqBody.PrPermitted, Type: reqBody.Type, Url: reqBody.Url, } @@ -743,7 +725,6 @@ func TestUserHandler_AddUserAccount(t *testing.T) { reqBody := schema.AddAccountRequest{ DisplayName: "", - PrPermitted: schema.PrPermitted(random.Bool()), Type: schema.AccountType(accountType), Url: random.AccountURLString(accountType), } @@ -760,7 +741,6 @@ func TestUserHandler_AddUserAccount(t *testing.T) { reqBody := schema.AddAccountRequest{ DisplayName: random.AlphaNumeric(), - PrPermitted: schema.PrPermitted(random.Bool()), Type: schema.AccountType(domain.AccountLimit), Url: random.RandURLString(), } @@ -798,7 +778,6 @@ func TestUserHandler_AddUserAccount(t *testing.T) { reqBody := schema.AddAccountRequest{ DisplayName: random.AlphaNumeric(), - PrPermitted: schema.PrPermitted(random.Bool()), Type: schema.AccountType(accountType), Url: random.AccountURLString(accountType), } @@ -807,7 +786,6 @@ func TestUserHandler_AddUserAccount(t *testing.T) { DisplayName: reqBody.DisplayName, Type: domain.AccountType(uint8(reqBody.Type)), URL: reqBody.Url, - PrPermitted: bool(reqBody.PrPermitted), } path := fmt.Sprintf("/api/v1/users/%s/accounts", userID) @@ -849,16 +827,13 @@ func TestUserHandler_EditUserAccount(t *testing.T) { userID := random.UUID() accountID := random.UUID() accountType := rand.N(domain.AccountLimit) - accountPermit := random.Bool() argsName := random.AlphaNumeric() - argsPermit := schema.PrPermitted(accountPermit) argsType := schema.AccountType(accountType) argsURL := random.AccountURLString(domain.AccountType(accountType)) reqBody := schema.EditUserAccountRequest{ DisplayName: &argsName, - PrPermitted: &argsPermit, Type: &argsType, Url: &argsURL, } @@ -867,7 +842,6 @@ func TestUserHandler_EditUserAccount(t *testing.T) { DisplayName: optional.FromPtr(&argsName), Type: optional.FromPtr(&accountType), URL: optional.FromPtr(&argsURL), - PrPermitted: optional.FromPtr(&accountPermit), } path := fmt.Sprintf("/api/v1/users/%s/accounts/%s", userID, accountID) @@ -882,16 +856,13 @@ func TestUserHandler_EditUserAccount(t *testing.T) { userID := random.UUID() accountID := random.UUID() accountType := rand.N(domain.AccountLimit) - accountPermit := random.Bool() argsName := random.AlphaNumeric() - argsPermit := schema.PrPermitted(accountPermit) argsType := schema.AccountType(accountType) argsURL := random.AccountURLString(domain.AccountType(accountType)) reqBody := schema.EditUserAccountRequest{ DisplayName: &argsName, - PrPermitted: &argsPermit, Type: &argsType, Url: &argsURL, } @@ -900,7 +871,6 @@ func TestUserHandler_EditUserAccount(t *testing.T) { DisplayName: optional.FromPtr(&argsName), Type: optional.FromPtr(&accountType), URL: optional.FromPtr(&argsURL), - PrPermitted: optional.FromPtr(&accountPermit), } path := fmt.Sprintf("/api/v1/users/%s/accounts/%s", userID, accountID) @@ -1540,7 +1510,6 @@ func TestUserHandler_GetMe(t *testing.T) { ID: random.UUID(), DisplayName: random.AlphaNumeric(), Type: accountType, - PrPermitted: random.Bool(), URL: random.AccountURLString(accountType), }, }, @@ -1552,7 +1521,6 @@ func TestUserHandler_GetMe(t *testing.T) { haccounts = append(haccounts, schema.Account{ Id: account.ID, DisplayName: account.DisplayName, - PrPermitted: schema.PrPermitted(account.PrPermitted), Type: schema.AccountType(account.Type), Url: account.URL, }) 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/infrastructure/migration/current.go b/internal/infrastructure/migration/current.go index 08e562fe..b0fac8de 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(), // ユーザーアカウントのprPermitted属性廃止 } } diff --git a/internal/infrastructure/migration/v3.go b/internal/infrastructure/migration/v3.go new file mode 100644 index 00000000..51041ed9 --- /dev/null +++ b/internal/infrastructure/migration/v3.go @@ -0,0 +1,41 @@ +// Package migration migrate current struct +package migration + +import ( + "time" + + "github.com/go-gormigrate/gormigrate/v2" + "github.com/gofrs/uuid" + "gorm.io/gorm" +) + +// v3 ユーザーアカウントのprPermitted属性廃止 +func v3() *gormigrate.Migration { + return &gormigrate.Migration{ + ID: "3", + Migrate: func(db *gorm.DB) error { + if err := db.Migrator().DropColumn(v3Account{}, "check"); err != nil { + return err + } + + return db. + Table("portfolio"). + Error + }, + } +} + +type v3Account struct { + ID uuid.UUID `gorm:"type:char(36);not null;primaryKey"` + Type uint8 `gorm:"type:tinyint(1);not null"` + Name string `gorm:"type:varchar(256)"` + URL string `gorm:"type:text"` + UserID uuid.UUID `gorm:"type:char(36);not null"` + Check bool `gorm:"type:boolean;not null;default:false"` + CreatedAt time.Time `gorm:"precision:6"` + UpdatedAt time.Time `gorm:"precision:6"` +} + +func (*v3Account) TableName() string { + return "accounts" +} diff --git a/internal/infrastructure/repository/main_test.go b/internal/infrastructure/repository/main_test.go index 9110ae07..ed4fa5ec 100644 --- a/internal/infrastructure/repository/main_test.go +++ b/internal/infrastructure/repository/main_test.go @@ -139,7 +139,6 @@ func mustMakeAccount(t *testing.T, repo repository.UserRepository, userID uuid.U DisplayName: random.AlphaNumeric(), Type: accountType, URL: random.AccountURLString(accountType), - PrPermitted: random.Bool(), } } diff --git a/internal/infrastructure/repository/model/user.go b/internal/infrastructure/repository/model/user.go index 999f3bda..160503c4 100644 --- a/internal/infrastructure/repository/model/user.go +++ b/internal/infrastructure/repository/model/user.go @@ -29,7 +29,6 @@ type Account struct { Name string `gorm:"type:varchar(256)"` URL string `gorm:"type:text"` UserID uuid.UUID `gorm:"type:char(36);not null"` - Check bool `gorm:"type:boolean;not null;default:false"` CreatedAt time.Time `gorm:"precision:6"` UpdatedAt time.Time `gorm:"precision:6"` } diff --git a/internal/infrastructure/repository/user_impl.go b/internal/infrastructure/repository/user_impl.go index c5844e8f..431c74ed 100644 --- a/internal/infrastructure/repository/user_impl.go +++ b/internal/infrastructure/repository/user_impl.go @@ -134,7 +134,6 @@ func (r *UserRepository) GetUser(ctx context.Context, userID uuid.UUID) (*domain ID: v.ID, DisplayName: v.Name, Type: domain.AccountType(v.Type), - PrPermitted: v.Check, URL: v.URL, }) } @@ -220,7 +219,6 @@ func (r *UserRepository) GetAccounts(ctx context.Context, userID uuid.UUID) ([]* result = append(result, &domain.Account{ ID: v.ID, Type: domain.AccountType(v.Type), - PrPermitted: v.Check, DisplayName: v.Name, URL: v.URL, }) @@ -242,7 +240,6 @@ func (r *UserRepository) GetAccount(ctx context.Context, userID uuid.UUID, accou result := &domain.Account{ ID: account.ID, Type: domain.AccountType(account.Type), - PrPermitted: account.Check, DisplayName: account.Name, URL: account.URL, } @@ -270,7 +267,6 @@ func (r *UserRepository) CreateAccount(ctx context.Context, userID uuid.UUID, ar Name: args.DisplayName, URL: args.URL, UserID: userID, - Check: args.PrPermitted, } err := r.h.WithContext(ctx).Create(&account).Error if err != nil { @@ -290,7 +286,6 @@ func (r *UserRepository) CreateAccount(ctx context.Context, userID uuid.UUID, ar ID: ver.ID, DisplayName: ver.Name, Type: domain.AccountType(ver.Type), - PrPermitted: ver.Check, URL: ver.URL, }, nil } @@ -303,9 +298,6 @@ func (r *UserRepository) UpdateAccount(ctx context.Context, userID uuid.UUID, ac if v, ok := args.URL.V(); ok { changes["url"] = v } - if v, ok := args.PrPermitted.V(); ok { - changes["check"] = v - } if v, ok := args.Type.V(); ok { changes["type"] = v } diff --git a/internal/infrastructure/repository/user_test.go b/internal/infrastructure/repository/user_test.go index 867c761d..f574df9b 100644 --- a/internal/infrastructure/repository/user_test.go +++ b/internal/infrastructure/repository/user_test.go @@ -168,7 +168,6 @@ func TestUserRepository_GetUser(t *testing.T) { ID: mockdata.MockAccounts[0].ID, DisplayName: mockdata.MockAccounts[0].Name, Type: domain.AccountType(mockdata.MockAccounts[0].Type), - PrPermitted: mockdata.MockAccounts[0].Check, URL: mockdata.MockAccounts[0].URL, }, }, @@ -271,13 +270,11 @@ func TestUserRepository_GetAccounts(t *testing.T) { DisplayName: random.AlphaNumeric(), Type: accountType1, URL: random.AccountURLString(accountType1), - PrPermitted: random.Bool(), }) account2 := mustMakeAccount(t, repo, user.ID, &urepository.CreateAccountArgs{ DisplayName: random.AlphaNumeric(), Type: accountType2, URL: random.AccountURLString(accountType2), - PrPermitted: random.Bool(), }) expected := []*domain.Account{account1, account2} @@ -305,13 +302,11 @@ func TestUserRepository_GetAccount(t *testing.T) { DisplayName: random.AlphaNumeric(), Type: accountType1, URL: random.AccountURLString(accountType1), - PrPermitted: random.Bool(), }) mustMakeAccount(t, repo, user.ID, &urepository.CreateAccountArgs{ DisplayName: random.AlphaNumeric(), Type: accountType2, URL: random.AccountURLString(accountType2), - PrPermitted: random.Bool(), }) got, err := repo.GetAccount(context.Background(), user.ID, account1.ID) @@ -341,13 +336,11 @@ func TestUserRepository_UpdateAccount(t *testing.T) { DisplayName: random.AlphaNumeric(), Type: accountType1, URL: random.AccountURLString(accountType1), - PrPermitted: random.Bool(), }) mustMakeAccount(t, repo, user.ID, &urepository.CreateAccountArgs{ DisplayName: random.AlphaNumeric(), Type: accountType2, URL: random.AccountURLString(accountType2), - PrPermitted: random.Bool(), }) accountType := optional.From(accountType3) @@ -355,12 +348,10 @@ func TestUserRepository_UpdateAccount(t *testing.T) { DisplayName: random.Optional(random.AlphaNumeric()), Type: accountType, URL: optional.From(random.AccountURLString(accountType3)), - PrPermitted: random.Optional(random.Bool()), } account1.DisplayName = args.DisplayName.ValueOr(account1.DisplayName) account1.Type = args.Type.ValueOr(account1.Type) account1.URL = args.URL.ValueOr(account1.URL) - account1.PrPermitted = args.PrPermitted.ValueOr(account1.PrPermitted) err = repo.UpdateAccount(context.Background(), user.ID, account1.ID, args) assert.NoError(t, err) @@ -387,13 +378,11 @@ func TestUserRepository_DeleteAccount(t *testing.T) { DisplayName: random.AlphaNumeric(), Type: accountType1, URL: random.AccountURLString(accountType1), - PrPermitted: random.Bool(), }) account2 := mustMakeAccount(t, repo, user.ID, &urepository.CreateAccountArgs{ DisplayName: random.AlphaNumeric(), Type: accountType2, URL: random.AccountURLString(accountType2), - PrPermitted: random.Bool(), }) err = repo.DeleteAccount(context.Background(), user.ID, account1.ID) diff --git a/internal/pkgs/mockdata/handler.go b/internal/pkgs/mockdata/handler.go index a1db9237..53b4c34a 100644 --- a/internal/pkgs/mockdata/handler.go +++ b/internal/pkgs/mockdata/handler.go @@ -404,7 +404,6 @@ func CloneHandlerMockUserAccountsByID() map[uuid.UUID][]schema.Account { hAccounts[a.UserID] = append(hAccounts[a.UserID], schema.Account{ DisplayName: a.Name, Id: a.ID, - PrPermitted: a.Check, Type: schema.AccountType(a.Type), Url: a.URL, }) diff --git a/internal/pkgs/mockdata/model.go b/internal/pkgs/mockdata/model.go index 0d626081..7a059336 100644 --- a/internal/pkgs/mockdata/model.go +++ b/internal/pkgs/mockdata/model.go @@ -56,7 +56,6 @@ func CloneMockAccounts() []model.Account { Name: "sample_account_display_name", URL: "https://twitter.com/sample_account", UserID: UserID1(), - Check: true, }, } } diff --git a/internal/pkgs/random/repository.go b/internal/pkgs/random/repository.go index a355d09f..b6c88ed1 100644 --- a/internal/pkgs/random/repository.go +++ b/internal/pkgs/random/repository.go @@ -129,7 +129,6 @@ func UpdateAccountArgs() *repository.UpdateAccountArgs { DisplayName: optional.From(AlphaNumeric()), Type: optional.From(rand.N(domain.AccountLimit)), URL: optional.From(RandURLString()), - PrPermitted: optional.From(Bool()), } return &a } @@ -140,7 +139,6 @@ func OptUpdateAccountArgs() *repository.UpdateAccountArgs { DisplayName: Optional(AlphaNumeric()), Type: Optional(rand.N(domain.AccountLimit)), URL: Optional(RandURLString()), - PrPermitted: Optional(Bool()), } return &a } 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. diff --git a/internal/usecases/repository/user_repository.go b/internal/usecases/repository/user_repository.go index f2ea62aa..0257ab60 100644 --- a/internal/usecases/repository/user_repository.go +++ b/internal/usecases/repository/user_repository.go @@ -25,14 +25,12 @@ type CreateAccountArgs struct { DisplayName string // 外部アカウントの表示名 Type domain.AccountType URL string - PrPermitted bool } type UpdateAccountArgs struct { DisplayName optional.Of[string] // 外部アカウントの表示名 Type optional.Of[domain.AccountType] URL optional.Of[string] - PrPermitted optional.Of[bool] } type UserRepository interface { From 86e0dc4428f76ed9f67c84f002dd181431307ac6 Mon Sep 17 00:00:00 2001 From: Tennessine699 Date: Sun, 12 Jan 2025 21:29:07 +0900 Subject: [PATCH 2/3] refactor: rename old v3Account --- internal/infrastructure/migration/v3.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/infrastructure/migration/v3.go b/internal/infrastructure/migration/v3.go index 51041ed9..e383635d 100644 --- a/internal/infrastructure/migration/v3.go +++ b/internal/infrastructure/migration/v3.go @@ -14,7 +14,7 @@ func v3() *gormigrate.Migration { return &gormigrate.Migration{ ID: "3", Migrate: func(db *gorm.DB) error { - if err := db.Migrator().DropColumn(v3Account{}, "check"); err != nil { + if err := db.Migrator().DropColumn(v3PreAccount{}, "check"); err != nil { return err } @@ -25,7 +25,7 @@ func v3() *gormigrate.Migration { } } -type v3Account struct { +type v3PreAccount struct { ID uuid.UUID `gorm:"type:char(36);not null;primaryKey"` Type uint8 `gorm:"type:tinyint(1);not null"` Name string `gorm:"type:varchar(256)"` @@ -36,6 +36,6 @@ type v3Account struct { UpdatedAt time.Time `gorm:"precision:6"` } -func (*v3Account) TableName() string { +func (*v3PreAccount) TableName() string { return "accounts" } From cded0ed9684d6324a631f97a2bd3dd09c21ed7e4 Mon Sep 17 00:00:00 2001 From: Tennessine699 Date: Sun, 12 Jan 2025 21:29:11 +0900 Subject: [PATCH 3/3] docs: update docs/dbschema --- docs/dbschema/README.md | 16 +++++++--------- docs/dbschema/accounts.md | 3 --- docs/dbschema/contest_team_user_belongings.md | 2 +- docs/dbschema/contest_teams.md | 8 ++++---- docs/dbschema/contests.md | 8 ++++---- docs/dbschema/project_members.md | 17 ++++++----------- docs/dbschema/projects.md | 11 +++++------ docs/dbschema/schema.json | 2 +- docs/dbschema/users.md | 6 ++---- 9 files changed, 30 insertions(+), 43 deletions(-) diff --git a/docs/dbschema/README.md b/docs/dbschema/README.md index b2c976c1..9e13e531 100644 --- a/docs/dbschema/README.md +++ b/docs/dbschema/README.md @@ -4,7 +4,7 @@ | Name | Columns | Comment | Type | | ---- | ------- | ------- | ---- | -| [accounts](accounts.md) | 8 | Twitterなどのアカウントテーブル | BASE TABLE | +| [accounts](accounts.md) | 7 | Twitterなどのアカウントテーブル | BASE TABLE | | [contests](contests.md) | 8 | コンテストテーブル | BASE TABLE | | [contest_teams](contest_teams.md) | 8 | コンテスト参加チームテーブル | BASE TABLE | | [contest_team_user_belongings](contest_team_user_belongings.md) | 4 | コンテストチームとユーザー関係テーブル | BASE TABLE | @@ -14,7 +14,7 @@ | [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 | +| [project_members](project_members.md) | 8 | プロジェクト所属者テーブル | BASE TABLE | | [users](users.md) | 7 | ユーザーテーブル | BASE TABLE | ## Relations @@ -38,13 +38,12 @@ erDiagram varchar_256_ name text url char_36_ user_id FK - tinyint_1_ check datetime_6_ created_at datetime_6_ updated_at } "contests" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link datetime_6_ since @@ -55,7 +54,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 +102,7 @@ erDiagram } "projects" { char_36_ id PK - varchar_32_ name + varchar_128_ name text description text link smallint_4_ since_year @@ -114,9 +113,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/accounts.md b/docs/dbschema/accounts.md index 718e2824..a0323792 100644 --- a/docs/dbschema/accounts.md +++ b/docs/dbschema/accounts.md @@ -14,7 +14,6 @@ CREATE TABLE `accounts` ( `name` varchar(256) DEFAULT NULL, `url` text DEFAULT NULL, `user_id` char(36) NOT NULL, - `check` tinyint(1) NOT NULL DEFAULT 0, `created_at` datetime(6) DEFAULT NULL, `updated_at` datetime(6) DEFAULT NULL, PRIMARY KEY (`id`), @@ -34,7 +33,6 @@ CREATE TABLE `accounts` ( | name | varchar(256) | NULL | true | | | アカウント名 | | url | text | NULL | true | | | アカウントのURL | | user_id | char(36) | | false | | [users](users.md) | ユーザーUUID | -| check | tinyint(1) | 0 | false | | | 公開可能かどうか | | created_at | datetime(6) | NULL | true | | | | | updated_at | datetime(6) | NULL | true | | | | @@ -65,7 +63,6 @@ erDiagram varchar_256_ name text url char_36_ user_id FK - tinyint_1_ check 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..57f2102e 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 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/project_members.md b/docs/dbschema/project_members.md index c2b99093..cfd97267 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 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..b8af1d0e 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":"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 `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":"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"}}}} diff --git a/docs/dbschema/users.md b/docs/dbschema/users.md index e16b757b..95a69924 100644 --- a/docs/dbschema/users.md +++ b/docs/dbschema/users.md @@ -74,7 +74,6 @@ erDiagram varchar_256_ name text url char_36_ user_id FK - tinyint_1_ check datetime_6_ created_at datetime_6_ updated_at } @@ -95,9 +94,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