pub async fn delete_role(pool: &Pool<MySql>, id: i64) -> Result<()>
Expand description
Deletes a role from the system.
This function permanently removes a role record from the database. It should be used with caution, as it affects user permissions and may impact system access for users with this role.
§Arguments
pool
- Database connection pool for executing the queryid
- Unique identifier of the role to delete
§Returns
Ok(())
- Successfully deleted the roleErr(anyhow::Error)
- Failed to delete the role
§Warning
This operation is irreversible. Before deleting a role, consider:
- Users with this role will lose the associated permissions
- Relationships in role_user and permissions_role tables may need to be cleaned up
- System functionality may be affected if critical roles are removed
§Important
Depending on the database schema, this operation may:
- Fail if foreign key constraints are enforced and the role is in use
- Leave orphaned records if cascading deletes are not configured
- Remove user access to system features
§Transaction Handling
This function uses a database transaction to ensure atomicity of the operation. If any part of the operation fails, the entire operation is rolled back.