Skip to main content

Deleting a user

Use this page to remove an account for good. In most cases it is better to set the status to Disabled: see Locking or disabling an account.

Before you start​

  • You hold the role ADMIN and can open Enterprise.
  • The account is not of type Admin or Sys, unless you are a super-user.
  • You accept that the deletion cannot be undone from the screen.
  • The user has never appeared in the Audit log. If the user has, the deletion is refused (see below).

Steps​

  1. Switch to Enterprise.
  2. Open Configuration > Users & Roles > Users, and click the user.
  3. On the General tab, click Delete.
  4. The card closes and you go back to the list.

There is no confirmation window in the metadata of the button. The deletion happens on the click.

What changes​

WhatChange
Table enterprise.userThe row is deleted.
Tables enterprise.user_warehouse and enterprise.user_api_keyThe user's rows are deleted too (foreign key ON DELETE CASCADE). The API keys stop working.
Table enterprise.audit_logA row of kind user_mutation with the old values (without the password hash).
Warehouse dataOther tables that store a user number (for example who created a receipt) keep the number. The code read for this page does not remove it.

What can go wrong​

MessageMeaningFix
Only a superuser can change or delete the superuser account {id}The account is Admin or Sys.Ask a super-user.
A foreign key error naming audit_log_user_id_fkeyThe user appears in enterprise.audit_log: as the actor of a change, or in a refused call. The foreign key from the audit log to the user has no ON DELETE rule, so the database refuses the deletion.Set Status to Disabled instead.

Because every administrator action is written to the audit log with the actor, an account that has ever changed a user, a role or a permission cannot be deleted. The same holds for a role named in a refused call (audit_log_role_id_fkey).

Not confirmed by code: the text the screen shows for the foreign key error. To verify: create a test user, sign in as that user and make a call that is refused (so an audit row is written), then try to delete the test user.