INSERT
, UPDATE
or DELETE
on a given table.INSERT
ing a list of rows Postgres will respect the order in which they appear in the query, so the reordering can happen beforehand.UPDATE
s is trickier because there is no ORDER BY
clause. The solution to this is to JOIN
on a subquery that SELECT
s with the option FOR UPDATE
.DELETE
has the same quircks as UPDATE
and it is too solved in the same way.Ecto.Multi
to perform INSERT
, UPDATE
or DELETE
on multiple tables the order to keep is between different operation. For example, supposing EntryA
was established to be modified before EntryB
, this is not correct::update_a
to be before :update_b
. When not possible, for instance if :update_a
depends on the result of :update_b
, this can be solved by acquiring the locks in a separate operation.