shared/model の SubjectID 不整合と Subject の ID 重複を解消#9
Merged
Conversation
Subject 構造体は Common (ID/CreatedAt/UpdatedAt) を埋め込みつつ、 本体側にも ID フィールドを宣言しており、Go のフィールド昇格の シャドウイングで本体側が勝つ前提に依存していた。両者の GORM タグは 完全一致しており、本体側 ID の存在は冗長で読みにくいだけだったため 削除する。Common.ID 経由で同じ主キー定義 (uuid + uuid_generate_v4) が引き継がれるため、Atlas が生成するスキーマは不変。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CancelledClass.SubjectID と RoomChange.SubjectID は uuid.UUID 型で 宣言されているのに対し、MakeupClass.SubjectID だけが string 型で gorm:"type:uuid" タグ付きになっており、SubjectID の Go 表現が不揃い だった。同じ subjects.id を参照する外部キーとして型を uuid.UUID に 統一する。GORM タグの type:uuid は維持しているため、Atlas が生成 するスキーマは不変。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
masaya-osuga
approved these changes
May 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
internal/shared/model/の構造体定義に 2 つの軽微な不整合があった。Atlas のatlas-provider-gorm経由で DDL を生成する際に挙動の違いはほぼないものの、Go コードからこれらの型を参照する場合に紛らわしいため、整理する。model.SubjectがCommon埋め込みと本体側ID uuid.UUIDを二重宣言しており、Go のフィールド昇格のシャドウイングに依存していた。両方の GORM タグは完全に一致 (type:uuid;primaryKey;default:uuid_generate_v4())。model.MakeupClass.SubjectIDのみstring型でgorm:\"type:uuid\"タグ付き。CancelledClass.SubjectID/RoomChange.SubjectIDはuuid.UUIDで揃っており、MakeupClassだけが浮いていた。変更点
internal/shared/model/subject.go: 本体側IDフィールドを削除し、Common.IDに一本化。internal/shared/model/makeup_class.go:SubjectIDをstringからuuid.UUIDに変更。gorm:\"type:uuid;not null;index\"タグは維持。いずれの変更も GORM タグの最終形は変わらないため、Atlas が生成する DDL は不変の想定。
確認
go build ./...go vet ./...task migrate:diffで空 diff になること (Docker が必要なためレビュー時に手元で確認をお願いしたい)🤖 Generated with Claude Code