Deleting user accounts - QutEcoacoustics/baw-server GitHub Wiki

We have limited engineering capability and most users of this software have requirements to keep generated research data.

In sizeable instances, permanent deletion of user accounts from a baw-server application could result in thousands of records being cascade deleted because we have referential integrity enabled.

As such permanent deletion of user accounts should be a very rare event. The default action users are allowed to take, is to deactivate their accounts if they no longer wish use the application.

However, it is useful to be able to hard delete accounts.

Deleting a user

untested instructions!

  1. Backup the database
  2. Open a rails console
  • RAILS_ENV=<xxx> rails console
  1. Authenticate as the Admin user
  • >> ApplicationController.allow_forgery_protection = false
  • >> app.post('/sign_in', {"user"=>{"email"=>"[email protected]", "password"=>"password"}}
  1. Find the user to delete
  • >> User.with_deleted.find(123)
  1. Finally, delete the record permanently
  • >> User.delete_fully!
⚠️ **GitHub.com Fallback** ⚠️