V02 of the package DDL: the subscription table ADR-0007, section 6 fixes,
named by StatifierRouter.Config.table/2 under the host's table prefix
and created in the host's Postgres schema when one is set.
subscriptions (ADR-0007, section 6): one row per live source
invocation, written by StatifierRouter.subscribe/3 and deleted by
StatifierRouter.cancel/2.
| Column | Type | Null |
|---|---|---|
id | bigserial, primary key | no |
binding_id | text | no |
execution_id | text | no |
invoke_id | text | no |
scope | text | no |
key | text | no |
inserted_at | utc_datetime_usec | no |
Every column is null: false, the shape V01's address table already
uses for everything but its terminal timestamp: a subscription with no
key is the refusal ADR-0007, section 6 names rather than a row.
Index: the unique
<table>_execution_id_binding_id_invoke_id_index on (execution_id, binding_id, invoke_id). That triple is the identity ADR-0007,
section 6 asks the row to distinguish - "two invocations of the same
binding in one execution do not cancel each other" - and its leading
column is the one StatifierRouter.SourceInvoke reads a row back by,
since the engine's cancellation carries an invoke_id and an execution
and no binding.
Under the default table prefix that name is 70 bytes, past the 63
Postgres keeps, so Postgres creates the index under its first 63 bytes.
This version still builds it that way, so a database that already ran
it and a fresh one hold the same index; StatifierRouter.Migrations.V03
renames it to <table>_invocation_index.
The table above is the layout with no layout option set. The
StatifierRouter.Migrations layout options reshape it only as this
version creates it, on the same terms as V01's tables: the
:leading_columns immediately after id, inserted_at following them
under timestamps_position: :leading, and each text column
:column_collations names declared with its collation. Its id is the
host repo's implicit primary key, as V01's is, or under the
:primary_key option the type and default that option names. A table
V01 already created is not touched.
A host that has already run V01 reaches this version with
StatifierRouter.Migrations.up(from: 2): from: names the first
version the host has not run and the walk includes it.
Summary
Types
The resolved storage and layout options StatifierRouter.Migrations hands each version.
Functions
Drops the V02 table; the Postgres schema and the V01 tables stay.
Creates the V02 table and its index.
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.