Skip to main content

would_orphan_developers

Function would_orphan_developers 

Source
pub async fn would_orphan_developers(
    db: &Db,
    user_id: i64,
    new_role: Option<Role>,
) -> Result<bool>
Expand description

Would the proposed change leave the system with zero active Developers?

new_role:

  • None → user is being deleted entirely.
  • Some(role) → user’s role is being changed to role.

Returns true only when:

  • exactly one active Developer exists, AND
  • the target user IS that Developer, AND
  • the action would remove their Developer status.

Used as a server-side guard in user-edit / user-delete handlers, and as a CLI warning before destructive role changes.