V03 of the package DDL: renames the subscription table's unique index to a name that fits in a Postgres identifier. It creates no table and no column.
StatifierRouter.Migrations.V02 names that index
<table>_execution_id_binding_id_invoke_id_index, which under the
default table prefix is
statifier_router_subscriptions_execution_id_binding_id_invoke_id_index,
70 bytes. Postgres keeps at most 63 bytes of an identifier and truncates
a longer one when it creates it, so a database that ran V02 holds the
index as statifier_router_subscriptions_execution_id_binding_id_invoke_i.
V02 itself is left as it shipped: every database that already ran it
keeps what it built, and this version renames what it finds.
Index: the unique <table>_invocation_index on (execution_id, binding_id, invoke_id), 47 bytes under the default table prefix. Only
the name changes: the columns, their order and the uniqueness are V02's,
and nothing is rebuilt.
up/1 renames the index from the name Postgres gave it under V02 - V02's
spelling cut to 63 bytes, at a character boundary, the way Postgres cuts
it - so it names the index exactly as the database holds it, whether or
not V02's name was truncated under the host's table prefix, and
Postgres has nothing to truncate. down/1 renames it back to that same
name.
Each direction renames only an index it finds under the name it renames
from (ALTER INDEX IF EXISTS), and otherwise does nothing. That is what
lets a host's migration that runs V03 on its own sit behind an earlier
one that already walked through V03 on a fresh database: the second run
finds the index already renamed and leaves it.
On SQLite (Ecto.Adapters.SQLite3) both directions do nothing. SQLite
keeps an identifier whole, so V02's index there already holds the name
V02 gave it, with nothing cut to repair, and SQLite has no
ALTER INDEX. The index keeps V02's name on SQLite; the package's
queries name its columns, never its name. Every other adapter runs the
rename above.
A host already running V02 reaches this version with
StatifierRouter.Migrations.up(from: 3): 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
Renames the subscription index back to the name V02 left it under; on SQLite, nothing.
Renames V02's subscription index to <table>_invocation_index; on SQLite, nothing.
Types
@type storage() :: %{ :table_prefix => String.t(), :prefix => String.t() | nil, optional(atom()) => term() }
The resolved storage options StatifierRouter.Migrations hands each version.