westonganger / active_snapshot

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

issues with soft deletes #50

Closed jayseo5953 closed 1 week ago

jayseo5953 commented 5 months ago

Hello all, so my project uses soft delete.

I have an order model that has many order_items. I create a snapshot of order. Then I destroy an order item and add a new order_item.

Next time I run snapshot_restore!, i get DB error saying the id of the order_item is duplicated since they are still in the database. Wonder if anyone solved this issue.. The error happens here

westonganger commented 1 month ago

At a glance it appears to be in correlation with a DB uniqueness index in your application. But its a little hard to say for sure.

@jayseo5953 I would be happy to work with you on a fix. Can you try writing a failing test/spec in a PR then we can work together to come up with a good solution.

Sorry for not responding to the original ask in a reasonable timeframe, thats not very like me. I promise I will make myself available to support you further, just so you know your time isnt being wasted.