When we delete a permission or role it is soft deleted.
Normally not an issue, but when creating a role with the same name or a permission against the same entity/screen and role, an error occurs stating the role name already exists or the permission mappnig already exists. It appears to still take soft deleted entries into account.
Is this intentional and if so what is the best way to manage this?
Thanks!
All unique indexes in the CUBA take into account delete_ts column.
Here is how indexes in Postgres DB look like:
Indexes:
“sec_permission_pkey” PRIMARY KEY, btree (id)
“idx_sec_permission_unique” UNIQUE, btree (role_id, permission_type, target) WHERE delete_ts IS NULL
Indexes:
“sec_role_pkey” PRIMARY KEY, btree (id)
“idx_sec_role_uniq_name” UNIQUE, btree (name) WHERE delete_ts IS NULL AND sys_tenant_id IS NULL
“idx_sec_role_uniq_name_sys_tenant_id_nn” UNIQUE, btree (name, sys_tenant_id) WHERE delete_ts IS NULL AND sys_tenant_id IS NOT NULL
I have also just seen the trigger in the documentation that should be populating DELETE_TS_NN from DELETE_TS, will implement that and see if it sorts the issue