Tracked, ordered, one-way data transformations for Ecto applications.
Pollard mirrors the Ecto migration system — same conventions, same workflow — but for data, not schema. Transforms are one-way (no rollback), tracked in a database table, and protected by advisory locks to prevent concurrent execution.
Usage
defmodule MyApp.Transforms.BackfillShopDetails do
use Pollard
transform "Backfill missing shop details" do
from(s in "shops", where: is_nil(s.details))
|> MyApp.Repo.update_all(set: [details: %{}])
end
endEach transform block runs in its own database transaction. Multiple blocks
per file break work into smaller transactions to avoid holding locks too long.
Running transforms
Via Mix task:
mix pollard.runVia release module:
Pollard.Runner.run(MyApp.Repo, path)
Summary
Functions
Defines a named transform block.
Functions
Defines a named transform block.
The block runs inside a Repo.transaction/1 call. Each transform in a file
gets its own transaction.
transform "Seed resource types" do
MyApp.Repo.insert_all("resource_types", [
%{name: "product", inserted_at: DateTime.utc_now()}
], on_conflict: :nothing)
end