fix(db): identity_binding 外键级联删除

账号被删除时其身份绑定随之外键级联清理,配合 LdapAuthService 的孤儿绑定自愈,防止残留绑定阻塞目录身份重新建号。

Signed-off-by: jangrui <admin@jangrui.com>
This commit is contained in:
jangrui 2026-08-01 13:04:44 +08:00
parent d7e41ec9ff
commit 88263eba36

View file

@ -0,0 +1,7 @@
-- identity_binding.user_id references user_account(id) without ON DELETE CASCADE. When an
-- account is removed, its bindings would otherwise survive and block the identity from being
-- provisioned again. Cascade the deletion so bindings never outlive their account.
ALTER TABLE identity_binding DROP CONSTRAINT identity_binding_user_id_fkey;
ALTER TABLE identity_binding
ADD CONSTRAINT identity_binding_user_id_fkey
FOREIGN KEY (user_id) REFERENCES user_account(id) ON DELETE CASCADE;