-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
soft delete users instead of destroying
- Loading branch information
Showing
9 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class SoftDeleteUser | ||
|
||
lev_routine | ||
|
||
protected | ||
|
||
def exec(user) | ||
return if user.nil? | ||
|
||
# Make sure object up to date, esp before dependent destroy stuff kicks in | ||
user.reload | ||
|
||
user.is_deleted = true | ||
user.save! | ||
|
||
user.external_ids.destroy_all | ||
user.external_uuids.destroy_all | ||
user.authentications.destroy_all | ||
user.application_users.destroy_all | ||
user.contact_infos.destroy_all | ||
user.save! | ||
|
||
user.reload | ||
user.first_name = 'Deleted' | ||
user.last_name = 'User' | ||
user.save! | ||
|
||
# security logs are read-only, but they contain PII so we force delete them for the user | ||
user.security_logs.delete_all | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddDeleteFlagToUser < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :users, :is_deleted, :boolean | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters