StatifierRouter.Migrations.V01 (StatifierRouter v0.2.0)

Copy Markdown View Source

V01 of the package DDL: the three tables the decision records fix, each named by StatifierRouter.Config.table/2 under the host's table prefix and created in the host's Postgres schema when one is set.

addresses (ADR-0002, section 1): (scope, document, key) -> execution_id.

ColumnTypeNull
idbigserial, primary keyno
scopetextno
documenttextno
keytextno
execution_idtextno
inserted_atutc_datetime_usecno
terminal_seen_atutc_datetime_usecyes, empty until the execution is first seen terminal

Indexes: the unique <table>_scope_document_key_index on (scope, document, key), and <table>_execution_id_index on execution_id, so the rows naming one execution are found without a scan.

dedupe (ADR-0003, section 6): one row per (binding_id, message_id) a delivery got past the dedupe step with.

ColumnTypeNull
idbigserial, primary keyno
binding_idtextno
message_idtextno
expires_atutc_datetime_usecno

Indexes: the unique <table>_binding_id_message_id_index on (binding_id, message_id), and <table>_expires_at_index on expires_at, for the reaper that deletes expired rows.

routing_ledger (ADR-0004, section 4): append-only, one row per recorded outcome.

ColumnTypeNull
idbigserial, primary keyno
binding_idtextno
message_idtextno
scopetextno
outcometextno
keytextyes, empty for key_refused
execution_idtextyes, empty where the outcome names no execution
reasontextyes, empty for every outcome but key_refused
inserted_atutc_datetime_usecno

Index: <table>_binding_id_inserted_at_index on (binding_id, inserted_at), since the ledger is read per binding.

Summary

Types

The resolved storage options StatifierRouter.Migrations hands each version.

Functions

Drops the V01 tables in reverse creation order; the Postgres schema stays.

Creates the V01 tables and their indexes.

Types

storage()

@type storage() :: %{table_prefix: String.t(), prefix: String.t() | nil}

The resolved storage options StatifierRouter.Migrations hands each version.

Functions

down(map)

@spec down(storage()) :: :ok

Drops the V01 tables in reverse creation order; the Postgres schema stays.

up(map)

@spec up(storage()) :: :ok

Creates the V01 tables and their indexes.