pub async fn delete_permission(pool: &Pool<MySql>, id: i64) -> Result<()>
Expand description
Deletes a permission from the system.
This function permanently removes a permission record from the database. It should be used with caution, as it affects role capabilities and may impact system access control.
§Arguments
pool
- Database connection pool for executing the queryid
- Unique identifier of the permission to delete
§Returns
Ok(())
- Successfully deleted the permissionErr(anyhow::Error)
- Failed to delete the permission
§Warning
This operation is irreversible. Before deleting a permission, consider:
- Roles with this permission will lose the associated capability
- Relationships in permissions_role table may need to be cleaned up
- System functionality may be affected if critical permissions are removed
§Important
Depending on the database schema, this operation may:
- Fail if foreign key constraints are enforced and the permission is in use
- Leave orphaned records if cascading deletes are not configured
- Affect 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.