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.
| Column | Type | Null |
|---|---|---|
id | bigserial, primary key | no |
scope | text | no |
document | text | no |
key | text | no |
execution_id | text | no |
inserted_at | utc_datetime_usec | no |
terminal_seen_at | utc_datetime_usec | yes, 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.
| Column | Type | Null |
|---|---|---|
id | bigserial, primary key | no |
binding_id | text | no |
message_id | text | no |
expires_at | utc_datetime_usec | no |
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.
| Column | Type | Null |
|---|---|---|
id | bigserial, primary key | no |
binding_id | text | no |
message_id | text | no |
scope | text | no |
outcome | text | no |
key | text | yes, empty for key_refused |
execution_id | text | yes, empty where the outcome names no execution |
reason | text | yes, empty for every outcome but key_refused |
inserted_at | utc_datetime_usec | no |
Index: <table>_binding_id_inserted_at_index on (binding_id, inserted_at), since the ledger is read per binding.
The tables above are the layout with no layout option set. The
StatifierRouter.Migrations layout options reshape them only as this
version creates them: :leading_columns go immediately after id on
all three, timestamps_position: :leading moves inserted_at to
follow them on the two tables that have one, and :column_collations
declares each named text column with its collation wherever a table
here has it.
The id above is the host repo's implicit primary key, a bigserial
unless the repo's :migration_primary_key says otherwise. Under the
StatifierRouter.Migrations :primary_key option it is instead an id
of the type and default the option names, on all three tables.
Summary
Types
The resolved storage and layout 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
@type storage() :: %{ :table_prefix => String.t(), :prefix => String.t() | nil, optional(:leading_columns) => [{atom(), {term(), keyword()}}], optional(:timestamps_position) => :trailing | :leading, optional(:column_collations) => [{atom(), String.t()}], optional(:primary_key) => keyword() | nil }
The resolved storage and layout options StatifierRouter.Migrations hands each version.