# `Ankusa.WAL.Postgres.Migration`
[🔗](https://github.com/jamescarr/ankusa/blob/ankusa_postgres-v0.1.0/ankusa_postgres/lib/ankusa/wal/postgres/migration.ex#L1)

Idempotent DDL bootstrap for `Ankusa.WAL.Postgres`, run once at connection
startup. Three tables:

  * `ankusa_wal`        — the log. `seq` is a `BIGSERIAL`; may have small gaps
    (a deduped or rolled-back row consumes a sequence value it never keeps)
    — harmless, since the contract only needs strictly-increasing seqs
    usable as a cursor, not perfect density.
  * `ankusa_wal_dedup`  — a **permanent** ledger, separate from `ankusa_wal` and
    never touched by `truncate_through/2`. This is what makes dedup survive
    WAL truncation: `ankusa_wal` rows get deleted once compacted to a segment,
    but the dedup key that row claimed is remembered forever, exactly
    mirroring `WAL.DiskLog`'s persisted `.dedup` snapshot. Carries its own
    `seq` column (filled in by the same transaction that writes `ankusa_wal`)
    rather than looking it up via a join to `ankusa_wal` — that join would stop
    finding a key once its owning row gets truncated.
  * `ankusa_wal_cursors` — one row per named reader cursor (`:dispatch`,
    `:compactor`), scoped by instance.

Every table is scoped by an `instance` column so one Postgres database can
back multiple `Ankusa.Instance`s — including the same instance name running on
many independent BEAM nodes at once, which is the whole point: coordination
happens through this shared, durable state, never through BEAM distribution.

# `run!`

```elixir
@spec run!(GenServer.server()) :: :ok
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
