EctoSavepoint (EctoSavepoint v0.1.0) View Source
Simple Ecto extension to use savepoints. Works with both postgrex and myxql.
Disclaimer: savepoints are not officially supported by Ecto for a reason. If you run into unexpected behaviour, please report so these cases can be documented here.
Add this line in your Repo:
use EctoSavepointAnd you can now do:
MyRepo.transaction(fn ->
MyRepo.insert(...)
MyRepo.savepoint("my_savepoint")
MyRepo.insert(...)
MyRepo.rollback_to_savepoint("my_savepoint")
MyRepo.insert(...)
end)This way, the insertions between savepoint and rollback are rolled back.
If you don't want to use, you can do the calls directly, as in:
EctoSavepoint.savepoint(MyRepo, "my_savepoint")
Link to this section Summary
Link to this section Functions
Specs
Creates a savepoint
Should be called within the same transaction that created the savepoint
Specs
Creates a savepoint
Should be called within a transaction