ExGAM.Ledger.Store.Postgres (ExGAM v0.1.0)

Copy Markdown View Source

PostgreSQL ledger adapter backed by the host application's Repo.

ExGAM intentionally has no database dependency. The application supplies :repo; by default SQL is executed dynamically through Ecto.Adapters.SQL.query/4 and transactions through the Repo's transaction/2 and rollback/1 callbacks. A different compatible SQL module may be supplied with :query_module.

Each logical batch is stored once as canonical bytes. A transaction-scoped advisory lock serializes one Domain, while a revision-guarded head update and database constraints preserve CAS and idempotency. Write transactions force synchronous_commit on; the host remains responsible for keeping PostgreSQL fsync enabled. The host provisions the schema in a migration using the SQL returned by migration_sql/1.

compressed: true optionally compresses each new canonical batch before storage. Readers accept compressed and plain batches independently of that setting. Indexed head/2 and read_batch/3 support bounded recovery input; full load/export remain explicit historical operations.

Summary

Functions

Returns the PostgreSQL DDL for a versioned host migration.

Returns the validated SQL namespace used for the ledger tables.

Functions

migration_sql(opts \\ [])

@spec migration_sql(keyword()) ::
  {:ok, %{up: [String.t()], down: [String.t()]}} | {:error, term()}

Returns the PostgreSQL DDL for a versioned host migration.

namespace(opts \\ [])

@spec namespace(keyword()) ::
  {:ok, %{schema: String.t(), table_prefix: String.t()}} | {:error, term()}

Returns the validated SQL namespace used for the ledger tables.