StatifierRouter.Migrations.V02 (StatifierRouter v0.3.0)

Copy Markdown View Source

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.

ColumnTypeNull
idbigserial, primary keyno
binding_idtextno
execution_idtextno
invoke_idtextno
scopetextno
keytextno
inserted_atutc_datetime_usecno

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.

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 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

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 V02 table; the Postgres schema and the V01 tables stay.

up(map)

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

Creates the V02 table and its index.