batch-jobs を shared/model 直接利用にリファクタ#8
Merged
Conversation
これまで batch-jobs モジュールは internal/modules/batch-jobs/database/
配下に独自の GORM モデルを持ち、Atlas マイグレーションの真実である
internal/shared/model と二重定義になっていた。スキーマドリフトの温床
だったため、リポジトリ層を shared/model を直接参照する形に移行する。
domain 層 (string ID 中心) は据え置き、repository/convert.go に model
↔ domain の境界変換 (uuid.UUID/string、date 文字列/time.Time、UUIDv5
文字列の uuid.Parse) を集約した。notification_upsert は値型リレーション
の auto-upsert を抑止するため Omit("Notification", "User") を追加して
いる。本コミットでは旧 database パッケージはまだ残しており、参照を
すべて剥がすところまでを行う。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
直前コミットで batch-jobs リポジトリ層は shared/model 直接利用に 切り替わり、internal/modules/batch-jobs/database 配下の GORM モデル は参照されなくなったため、9 ファイルをまとめて削除する。 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/は Atlas マイグレーション (atlas.hcl→atlas-provider-gorm) の真実の供給源として参照されているが、これまで Go コードからは一切 import されていなかった。一方internal/modules/batch-jobs/database/が同じテーブル群に対する独自 GORM モデルを持っており、ID 型 (stringvsuuid.UUID)、共通フィールド (Common埋め込みの有無)、dateカラムの Go 表現 (time.Timevsstring) などで二重定義になっていた。スキーマドリフトの温床になるため、shared/model を Go コードからも正として使う形に揃える。変更点
internal/modules/batch-jobs/database/*.go全 9 ファイルinternal/modules/batch-jobs/repository/convert.gomodel↔domainの境界変換 (uuid.UUID↔string、date文字列 ↔time.Time、UUIDv5 文字列のuuid.Parse) を集約internal/modules/batch-jobs/repository/の 8 ファイルshared/modelに切替domain層 (string ID 中心) は据え置き、変換は repository 境界のみで実施notification_upsertは値型リレーション (Notification/User) の auto-upsert を抑止するためOmit(\"Notification\", \"User\")を追加notification_list_pendingの集計キーはuuid.UUID.String()を経由shared/model側の構造体は無変更。確認
go build ./...go vet ./...go test ./...(batch-jobs 配下にテストは無いが既存テストは全てパス)atlas migrate diff --env localが空 diff であること (Docker が必要なためレビュー時に手元で確認をお願いしたい)cmd/build-class-change-notifications-jobのローカル実行でnotifications/notification_target_usersの upsert と*_list_by_date系の読み取りが期待通り動作することcmd/dispatch-notifications-jobの pending 取得 → mark notified が機能すること補足
shared/model 側に既存の不整合 (
Subjectの ID 二重宣言、MakeupClass.SubjectIDの型不揃い) があるが、本 PR のスコープからは外している。別 PR で整理予定。🤖 Generated with Claude Code