Idempotent DDL bootstrap for Ankusa.WAL.Postgres, run once at connection
startup. Three tables:
ankusa_wal— the log.seqis aBIGSERIAL; 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 fromankusa_waland never touched bytruncate_through/2. This is what makes dedup survive WAL truncation:ankusa_walrows get deleted once compacted to a segment, but the dedup key that row claimed is remembered forever, exactly mirroringWAL.DiskLog's persisted.dedupsnapshot. Carries its ownseqcolumn (filled in by the same transaction that writesankusa_wal) rather than looking it up via a join toankusa_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.Instances — 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.
Summary
Functions
@spec run!(GenServer.server()) :: :ok