GTFSのDBマイグレーション - #51
hikaru-0602 wants to merge 9 commits into
Conversation
kantacky
left a comment
There was a problem hiding this comment.
Standards軸・Spec軸で確認した指摘をインラインコメントとして残します。
| Common | ||
|
|
||
| ServiceID string `gorm:"not null;index"` | ||
| Calendar *Calendar `gorm:"belongsTo;foreignKey:ServiceID;references:ServiceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` |
There was a problem hiding this comment.
belongsTo はgormの公式タグとして存在しないキーです。既存コード(例: room_change.go)は gorm:"foreignKey:XxxID;constraint:..." のみを使っており、belongsTo は無効な値として単に無視されます。削除をお願いします。
There was a problem hiding this comment.
公式にはタグはないけどライブラリ自体には存在してる
https://github.com/go-gorm/gorm/blob/master/schema/relationship.go
これないとHasOne判定になってマイグレーション失敗するからタグ残すことにした
これでも問題はないけど,削除した方が良いなら対応します
| Origin *Stop `gorm:"belongsTo;foreignKey:OriginID;references:StopID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` | ||
| DestinationID string `gorm:"not null;index"` | ||
| Destination *Stop `gorm:"belongsTo;foreignKey:DestinationID;references:StopID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` | ||
| Price float64 `gorm:"not null"` |
There was a problem hiding this comment.
GTFS標準のfare_rules.txtにはprice列は存在せず、price/currency_typeはfare_attributes.txt側(fare_idで紐付け)の責務です。このモデルはfare_attributes相当を作らずpriceを直接埋め込んでおり、正規化されたGTFSモデルから逸脱しています。同一fare_idを複数ルールで共有するケースやcurrency_type等の拡張に対応できなくなるため、設計意図を確認したいです。
There was a problem hiding this comment.
本来は,子どもと大人で料金が異なる場合とかを想定してテーブル分かれてるんだけど,実データ見たところ一律料金だったため,テーブルを分ける必要は無いと判断.
将来子ども料金とか作られたら対応は必要になる.
| Common | ||
|
|
||
| StopID string `gorm:"not null;uniqueIndex"` | ||
| StopName string `gorm:"not null"` |
There was a problem hiding this comment.
GTFS仕様上 stop_lat/stop_lon(緯度経度)はConditionally Requiredで、経路探索・地図表示に実質必須のフィールドです。現状StopIDとStopNameのみで位置情報が完全に欠落しており、機能上致命的な漏れの可能性があります。意図的な省略でなければ追加をお願いします。
There was a problem hiding this comment.
今回の仕様には緯度経度は必要ないと判断.
もし,現在地から一番近いバス停を自動選択といった機能を追加するならその際に対応が必要
| type CalendarDate struct { | ||
| Common | ||
|
|
||
| ServiceID string `gorm:"not null;index"` |
There was a problem hiding this comment.
ServiceIDがCalendarへのNOT NULL FKになっていますが、GTFS仕様上はcalendar.txtにservice_idが存在せず、calendar_dates.txtのみで運行日を定義するケースも許容されています。そのケースの取り込み時にFK制約違反になる可能性があるため、Calendar側の存在を前提にしてよいか確認したいです。
FareRuleとFCMTokenの登録順が入れ替わっていたため修正。 Co-authored-by: Cursor <cursoragent@cursor.com>
Deploying fun-dotto-server-docs with
|
| Latest commit: |
5a6c4b5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ac92f282.fun-dotto-server-docs.pages.dev |
| Branch Preview URL: | https://feature-add-gtfs-migration.fun-dotto-server-docs.pages.dev |
変更点
GTFSのDBモデル定義,マイグレーション実行