Repository navigation
feat(db): ロールの変更履歴と、最後の管理者を外せない制約を加える(U-5) - #83
Merged
Merged
Conversation
U-5 の 1 つ目の PR(データベース)。どちらもトリガーで行い、どの API から 操作しても破れないようにした(components.md 3.4)。 - member_role_history(FR-5.3):member_roles の追加・削除のたびに、 トリガーが「誰の・どのロールを・付与か剥奪か・誰が・いつ」を 1 行書く。 アプリには読み取りしか許さないので、消したり書き換えたりできない。 member_status_history と同じ方式。アプリ以外からの変更は 'operator' - 最後の管理者(FR-5.2):role.manage を含むロールが外れたあと、 role.manage を持つ部員が残らなければ取り消す。U-6 で退部時に ロールを外すときも、この確認を通る - Drizzle のスキーマと components.md 3.6 の表に履歴の表を加えた テストを追加した。履歴を書くトリガー、最後の管理者を守るトリガーを それぞれ外すと失敗することを確かめてある。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vm1iXpgdwQfcWuyNzX9KF7
This was referenced Nov 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.
U-5(引き継ぎ)を 4 つに分けた PR の 1 つ目で、データベースの部分です。FR-5.2・FR-5.3 に対応します。
変更
1. ロールの変更履歴(FR-5.3)
新しい表
member_role_historyを追加しました。member_idrole_keyactiongrant(付与)かrevoke(剥奪)actor_user_idoperatorになりますoccurred_atmember_rolesに行が追加・削除されるたびに、トリガーが 1 行書きます。アプリが書き忘れることはありませんmember_status_history)と同じ方式ですcomponents.md3.6)。誰に見せるかは、PR 3 の API がrole.manageで決めます2. 最後の管理者を外せない(FR-5.2)
role.manageを含むロールが外れたあと、role.manageを持つ部員が 1 人も残らない場合は、エラーにして取り消します。U-6 で退部時にロールを外すときも、この確認を通ります。その他
components.md3.6 の表に、履歴の表の扱いを追記しました検証
role.manageを含まないロールは、最後の管理者からでも外せるoperatorとして残るdatabasejob で確認しますこの後の PR
Generated by Claude Code