AE
Ash Elixir•3w ago
AngyL75

Ash Paper Trail, destroy action

I would like to know how to remove the versions of an object that I deleted. I have used a destroy action on a parent object. this parent object has a version system in place with the following configuration:
paper_trail do
primary_key_type :uuid
only_when_changed? true
change_tracking_mode :changes_only
store_action_name? true
store_action_inputs? true
ignore_attributes [:inserted_at, :updated_at]
reference_source? false
# for multitenancy
attributes_as_attributes [:organization_id]
belongs_to_actor :actor, CauseBeacon.Accounts.User, public?: false
end
paper_trail do
primary_key_type :uuid
only_when_changed? true
change_tracking_mode :changes_only
store_action_name? true
store_action_inputs? true
ignore_attributes [:inserted_at, :updated_at]
reference_source? false
# for multitenancy
attributes_as_attributes [:organization_id]
belongs_to_actor :actor, CauseBeacon.Accounts.User, public?: false
end
I would like to be able to delete all the related versions in the "paper-trail" table, related to the row/object that I want to destroy. when using reference_source? true, I fail to destroy my row. now it destroy my row, but I have new row in my version, every time I am destroying an object (since I do not have the
ignore_actions [:destroy]
ignore_actions [:destroy]
) Regards, Angy
3 Replies
ZachDaniel
ZachDaniel•3w ago
You can use the version mixin to configure the reference from the versions table to the source table in the Postgres section Search for "mixin" in paper trail, and "references" in ash_Postgres
allenwyma
allenwyma•2w ago
@AngyL75 i've marked the answer on the card for this issue: you can check out cascade_destroy: it's in the latest book update! 🙂
allenwyma
allenwyma•2w ago
GitHub
Support for on_delete: :delete_all · Issue #177 · ash-project/ash...
Is your feature request related to a problem? Please describe. I didn't find a simple way to modify the on_delete behaviour for postgres, so I generated a migration and manually changed the beh...

Did you find this page helpful?