From 88263eba361c1af03c3c0e0674c9865def1a35b7 Mon Sep 17 00:00:00 2001 From: jangrui Date: Sat, 1 Aug 2026 13:04:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(db):=20identity=5Fbinding=20=E5=A4=96?= =?UTF-8?q?=E9=94=AE=E7=BA=A7=E8=81=94=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 账号被删除时其身份绑定随之外键级联清理,配合 LdapAuthService 的孤儿绑定自愈,防止残留绑定阻塞目录身份重新建号。 Signed-off-by: jangrui --- .../db/migration/V42__identity_binding_cascade_delete.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 server/skillhub-app/src/main/resources/db/migration/V42__identity_binding_cascade_delete.sql diff --git a/server/skillhub-app/src/main/resources/db/migration/V42__identity_binding_cascade_delete.sql b/server/skillhub-app/src/main/resources/db/migration/V42__identity_binding_cascade_delete.sql new file mode 100644 index 00000000..e4c6284e --- /dev/null +++ b/server/skillhub-app/src/main/resources/db/migration/V42__identity_binding_cascade_delete.sql @@ -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;