westonganger / active_snapshot

Simplified snapshots and restoration for ActiveRecord models and associations with a transparent white-box implementation
MIT License
103 stars 16 forks source link

Ability to restore in order of has_snapshot_children to assist restore with foreign key constraints #37

Closed westonganger closed 1 year ago

westonganger commented 1 year ago

Alternative to #33 to allow to work with foreign key constraints

Adds an option to Snaphot#restore!(order_by_definition: true) which will attempts to dynamically set the restore order of the records according to the current has_snaphot_children definition.

At this point not going to merge this just going to leave it here if someone needs the code.

Pros of this approach:

Cons of this approach

westonganger commented 1 year ago

Closing as this is just for example. This gem will not support foreign key constraints it adds too much complication.