Skip to content

feat: 依存エンティティのFKにOnDelete CASCADEを追加#41

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1783509562-on-delete-cascade
Open

feat: 依存エンティティのFKにOnDelete CASCADEを追加#41
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1783509562-on-delete-cascade

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 8, 2026

Copy link
Copy Markdown

変更点

親エンティティ削除時に、それに依存する子・中間テーブルのレコードが取り残されないよう、GORM モデル(internal/shared/model)の外部キー制約に OnDelete:CASCADE を追加した。マイグレーションファイルは含めない(別途 mise run migrate:diff で生成する運用)。

追加した OnDelete:CASCADE(いずれも従属関係・中間テーブル):

  • Subject 配下の詳細/子テーブル: cancelled_classes, makeup_classes, room_changes, timetable_items, subject_eligible_attributes, subject_requirements, subject_faculties (subject_id)
  • 中間テーブルの両辺:
    • course_registrationssubjects, users
    • faculty_roomsfaculties, rooms
    • subject_facultiesfaculties
    • timetable_item_roomstimetable_items, rooms

意図的に CASCADE を付けなかったもの:

  • subjects.syllabus_idsyllabuses: シラバスは Subject のマスタ的参照であり、削除で Subject 連鎖削除は過剰なため NO ACTION のまま
  • room_changes.original_room_id / new_room_idrooms: rooms はマスタデータの参照であり、削除時に room_changes を消すのは不適切なため NO ACTION のまま

なお fcm_tokensusers, notification_target_usersnotifications/users は既に CASCADE 済み。

確認

  • go build ./... / go vet ./... / gofmt -l . OK

Link to Devin session: https://app.devin.ai/sessions/7b2fcdbd708e410aadf9035ff7dcaf0d
Requested by: @kantacky

Co-Authored-By: Kanta Oikawa <iam@kantacky.com>
@devin-ai-integration devin-ai-integration Bot requested review from a team, Hosoda-abo, hikaru-0602 and kantacky July 8, 2026 11:19
@kantacky kantacky self-assigned this Jul 8, 2026
@devin-ai-integration devin-ai-integration Bot requested a review from sayo-o518 July 8, 2026 11:19
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploying fun-dotto-server-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3d6f161
Status: ✅  Deploy successful!
Preview URL: https://f7561d30.fun-dotto-server-docs.pages.dev
Branch Preview URL: https://devin-1783509562-on-delete-c.fun-dotto-server-docs.pages.dev

View logs

@devin-ai-integration

Copy link
Copy Markdown
Author
Original prompt from Kanta

SYSTEM:
=== BEGIN THREAD HISTORY (in #times_kantacky) ===
<most_recent_message>
Kanta Oikawa (U071TQ4TLTB): @Devin
fun-dotto/server で、OnDelete CASCADEが必要そうなところには追加して
</most_recent_message>
=== END THREAD HISTORY ===

Thread URL: https://furarico.slack.com/archives/C08DF8VMA8N/p1783509227547529?thread_ts=1783509227.547529&amp;cid=C08DF8VMA8N

The latest message is the one right above that tagged you. The <most_recent_message> is the message that you should use to guide your goals + task for this session, and you should use the rest of the slack thread as context.

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

2 participants