Skip to content

feat: buildingsの主キーをDB内部専用にし、building_no/keyを新設 - #4

Merged
shikasan2127 merged 3 commits into
mainfrom
feat/building-no-and-key
Oct 2, 2026
Merged

shikasan2127 merged 3 commits into
mainfrom
feat/building-no-and-key

Conversation

@shikasan2127

Copy link
Copy Markdown
Member

Summary

  • buildings.csvのid(1,3,4,5...と欠番あり)がbuildings.idとしてそのまま主キーに使われていたが、本来これは安定したPKではなく外部公開用の識別子だったため、buildings.idをDB内部専用のSERIAL主キーに変更
  • 旧idはbuilding_no(UNIQUE)として分離。nodes/rooms/photos.building_idおよびAPIのbuilding_idは引き続きbuilding_noを参照するため、既存の挙動・API契約は変更なし
  • db/seeds/memo.csvの安定文字列キー(例: B1, AIT_PLAZA)をbuildings.keyとして取り込むSeedBuildingKeysを追加
  • docs/schema.mdに、将来的にAPIをkeyベースへ移行する方針と残タスクをTODOとして明記

Test plan

  • go build ./...
  • go vet ./...
  • golangci-lint run ./...(0 issues)
  • 実DB環境でbuildings/nodes/rooms/photosのseed投入と/buildings系APIの応答を確認

🤖 Generated with Claude Code

shikasan2127 and others added 3 commits October 2, 2026 18:50
buildings.csvのid(1,3,4,5...と欠番あり)がbuildings.idとして
主キーに使われていたが、本来これは安定したPKではなく外部公開用の
識別子だった。buildings.idをDB内部専用のSERIAL主キーとし、
旧idはbuilding_no(UNIQUE)として分離。nodes/rooms/photos.building_id
やAPIのbuilding_idは引き続きbuilding_noを参照するため、既存の
挙動・API契約は変わらない。

あわせてdb/seeds/memo.csvの安定文字列キー(例: B1, AIT_PLAZA)を
buildings.keyとして取り込めるようSeedBuildingKeysを追加。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
現在APIのbuilding_idはbuildings.building_no(数値、欠番あり)を
参照しているが、将来的に安定した文字列キーbuildings.keyへ移行する
方針のため、移行に必要な対応事項をdocs/schema.mdにTODOとして明記。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
buildings.csv自体にkey列(memo.csv由来の安定文字列キー)を追加したため、
別ファイル(memo.csv)からUPDATEするSeedBuildingKeysは不要になった。
SeedBuildingsをid,key,name,description,affiliation(5列)形式に対応させ、
memo.csvの投入ステップを削除。buildings.csv側がkeyの唯一のソースとなる。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@shikasan2127
shikasan2127 merged commit b317aad into main Oct 2, 2026
3 checks passed
@shikasan2127
shikasan2127 deleted the feat/building-no-and-key branch October 2, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant