# Challenges You can choose any of the challenges below, or suggest a new one for this session. ## Soft-Delete ### Goal: Implement a soft-delete mechanism similar to what many ORM solutions provide, where records in the database are virtually deleted, allowing users to retrieve them when needed, undoing the operation. <details> <summary>Example</summary> <br /> In Ruby on Rails, Active Record provide features that would allow one to implement such a feature where the following would be possible: ```rb= user = User.find(user_id) user.destroy! # seamlessly soft-deleted user = User.find(user_id) # error is raised user.restore! user = User.find(user_id) # user is found ``` </details> ## Record Change History ### Goal: Implement a change history solution for database records, where one can track the updates made to a given record, e.g. which columns were updated and what the previous vs current values are. <details> <summary>Example</summary> <br /> Using Ruby on Rails as an example, the following could be a valid API for the solution: ```rb= user = User.create(first_name: "Alice", last_name: "Doe", age: 35) user.update first_name: "Ali" user.update first_name: "Al", age: 35 first_name_changes = user.change_history.where(attribute: :first_name) first_name_changes.size => 2 first_name_changes.first.attribute => "first_name" first_name_changes.first.old => "Alice" first_name_changes.first.new => "Ali" first_name_changes.first.created_at => Sun, 27 Nov 2022 22:27:21 EST -05:00 first_name_changes.second.attribute => "first_name" first_name_changes.second.old => "Ali" first_name_changes.second.new => "Al" first_name_changes.first.created_at => Sun, 27 Nov 2022 22:49:39 EST -05:00 ``` </details>