Ash FrameworkAF
Ash Framework8mo ago
40 replies
Failz

ash_double_entry and updating transfers

I see a unit test that is capable of updating a transfer.

However I cannot get it to work and see this error.

* ** (CaseClauseError) no case clause matching: {:error, "Cannot destroy a transfer atomically if balances must be destroyed manually, or if balance is being updated"}


I am using Postgres (16.1) and saw this in the docs:

transfer do
    # configure the other resources it will interact with
    account_resource YourApp.Ledger.Account
    balance_resource YourApp.Ledger.Balance

    # you only need this if you are using `postgres`
    # and so cannot add the `references` block shown below

    # destroy_balances? true
  end


cascading destroys

If you are not using a data layer capable of automatic cascade deletion, you must add destroy_balances? true to the transfer resource! We do this with the references block in ash_postgres as shown above.


I've played with both of these settings but still come up against the error I posted above. The mention of these two settings is confusing. Postgres is capable of "automatic cascade deletion", no?

What am I missing?

Note: There's no ash_double_entry tag.
Solution
update :update_balance do
  change get_and_lock_for_update()
end
Was this page helpful?