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.
untested instructions!
- Backup the database
- Open a rails console
RAILS_ENV=<xxx> rails console
- Authenticate as the
Admin
user
>> ApplicationController.allow_forgery_protection = false
>> app.post('/sign_in', {"user"=>{"email"=>"[email protected]", "password"=>"password"}}
- Find the user to delete
>> User.with_deleted.find(123)
- Finally, delete the record permanently
>> User.delete_fully!