Permission needs unique index and partial unique indexes to prevent duplicate due to get_or_create()
14 Dec 2015
get_or_create() is safe only if filtered keys covers at least a unique index (partial or not).
#1 Updated by Benjamin Dauvergne about 4 years ago
- Status changed from Nouveau to Solution déployée
To find and remove existing duplicates:
delete from a2_rbac_permission where id in (select p.id from a2_rbac_role_permissions as rp right outer join a2_rbac_permission p on rp.permission_id = p.id left outer join a2_rbac_role as r on r.admin_scope_ct_id = 66 and r.admin_scope_id = p.id where rp.id is null and r.id is null);
commit 8a23dc8be0f9b1dd0995da6479bf439b9fc7c1e2 Author: Benjamin Dauvergne <email@example.com> Date: Mon Dec 14 14:46:04 2015 +0100 a2_rbac: add a partial index to prevent duplicate permissions (fixes #9234)