The exterminator of application records. #GDPR
gem install dalek
But not yet! To be uploaded...
Describing the deletions as a data structure
class DeleteUser < Dalek
deletion_tree 'User', {
_before: ->(users) { users.none(&:active?) },
posts: {
comments: {commented_posts: :delete},
},
comments: :delete,
avatars: ->(avatars) { avatars.update!(user_id: nil, image: nil) },
}
end
Extermination
user = User.find_by doomed: true
DeleteUser.execute user # => true/false result, paraphrased Ta-da
http://nithinbekal.com/posts/ruby-tco/ https://robots.thoughtbot.com/referential-integrity-with-foreign-keys