Permissions & Roles soft deleted preventing creation of same name

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?


What database do you use?

All unique indexes in the CUBA take into account delete_ts column.

Here is how indexes in Postgres DB look like:

“sec_permission_pkey” PRIMARY KEY, btree (id)
“idx_sec_permission_unique” UNIQUE, btree (role_id, permission_type, target) WHERE delete_ts IS NULL

“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 am using MySQL and the index I have on SEC_PERMISSION is IDX_SEC_PERMISSION_UNIQUE which is based on columns:


I’m thinking looking that the DELETE_TS_NN should be DELETE_TS?

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