Skip to content

Commit 534edae

Browse files
newt239claude
andcommitted
fix: プロフィールupsert処理に関する複数の不具合修正
- parent_homephone_numberにDEFAULT ''を追加し、初回INSERT時のNOT NULL制約違反を防止 - サインアップ時にuser_private_profilesの初期レコードを作成するように修正 - DuplicateUpdateのbool返り値を修正し、UPDATE成功時にtrueを返すように変更 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent be1af87 commit 534edae

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSERT INTO user_private_profiles (user_id, first_name, last_name, first_name_kana, last_name_kana, phone_number, address, parent_name, parent_cellphone_number, parent_homephone_number, parent_address) VALUE (UUID_TO_BIN(/*userId*/'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'), '', '', '', '', '', '', '', '', '', '');

pkg/db/transaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (t *transactionClient) DuplicateUpdate(insertQueryPath string, updateQueryP
8282
if err != nil {
8383
return nil, true, err
8484
}
85-
return res, false, nil
85+
return res, true, nil
8686
}
8787
return nil, false, err
8888
}

pkg/google_auth/post_signup_callback.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,11 @@ func createDefaultUser(dbClient db.TransactionClient, userId string, studentNumb
7575
if rerr != nil {
7676
return rerr
7777
}
78+
_, err = dbClient.Exec("sql/user/insert_user_private_default.sql", &struct {
79+
UserId string `twowaysql:"userId"`
80+
}{UserId: userId}, true)
81+
if err != nil {
82+
return &response.Error{Code: http.StatusInternalServerError, Level: "Error", Message: "不明なエラーが発生しました", Log: err.Error()}
83+
}
7884
return nil
7985
}

schema/user_private_profiles.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CREATE TABLE user_private_profiles
1313
parent_last_name VARCHAR(255) NOT NULL DEFAULT '',
1414
parent_first_name VARCHAR(255) NOT NULL DEFAULT '',
1515
parent_cellphone_number VARCHAR(32) NOT NULL,
16-
parent_homephone_number VARCHAR(32) NOT NULL,
16+
parent_homephone_number VARCHAR(32) NOT NULL DEFAULT '',
1717
parent_address VARCHAR(255) NOT NULL,
1818
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
1919
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

0 commit comments

Comments
 (0)