pub async fn delete_user(pool: &Pool<MySql>, id: i64) -> Result<()>
Expand description
Hard deletes a user from the system.
This function permanently removes a user record from the database. It should be used with caution, as it typically has significant implications for data integrity and user experience.
§Arguments
pool
- Database connection pool for executing the queryid
- Unique identifier of the user to delete
§Returns
Ok(())
- Successfully deleted the userErr(anyhow::Error)
- Failed to delete the user
§Warning
This operation is irreversible. Consider the implications before deleting users, especially those with existing data or relationships in the system. For many applications, it may be preferable to deactivate users by setting their ‘active’ flag to false or using soft_delete_user rather than deleting them completely.
§Note
Due to CASCADE DELETE constraints in the database, this will automatically delete all related records in user_meta, user_pii, user_sessions, and other tables with foreign key relationships to the user.