Skip to main content

MIGRATION_2

Constant MIGRATION_2 

pub const MIGRATION_2: &str = "-- Migration 2 \u{2014} the projection store\'s checkpoint.\n--\n-- The number is this directory\'s sequence, so that an operator applying the\n-- files in lexical order gets a working database for both roles. It is NOT this\n-- store\'s own version: this is the first migration of the projection role, which\n-- has its own lineage exactly as `happenstance-sqlite` and `happenstance-postgres`\n-- do. The two roles are separated by features and a consumer taking only\n-- `event-store` never applies this file.\n--\n-- Templated and split for the reasons migration 1 states in full: there is no\n-- session to hold a `search_path` in, and the endpoint\'s `query` field takes\n-- exactly one statement.\n--\n-- The suite\'s own probe read model is deliberately NOT here. It lives as a\n-- constant behind the `conformance` feature, because a test table shipped inside\n-- an application\'s database is a defect no test in this repository could catch \u{2014}\n-- every test enables the feature. A `.sql` file in this directory is, by\n-- construction, something an operator applies.\n\nCREATE SCHEMA IF NOT EXISTS @schema@;\n\nCREATE TABLE IF NOT EXISTS @checkpoint@ (\n    -- The `ProjectionId`, verbatim. `text` rather than a bounded `varchar`: the\n    -- contract validates the identifier and this column is not the place to\n    -- restate a limit that would then disagree with it.\n    projection_id text   NOT NULL PRIMARY KEY,\n\n    -- A `SequencePosition`, which is a `NonZeroU64`, in a signed `bigint`. The\n    -- gap is real and is read back through a fallible conversion rather than by\n    -- a cast that would turn a corrupt row into a plausible position. The column\n    -- carries the cheap half of the same guard so that a wrong value cannot be\n    -- written in the first place.\n    position      bigint NOT NULL CHECK (position > 0),\n\n    -- STORED, never inferred. `Checkpoint` is three states and `Authority` is\n    -- two, and the third state \u{2014} `NeverRun` \u{2014} is the ABSENCE of this row. That\n    -- is why `reset` deletes rather than writing a sentinel: a sentinel position\n    -- would make a reset indistinguishable from a commit at the first position.\n    --\n    -- Text rather than an enum type. A `CREATE TYPE` is a second schema object\n    -- to migrate and one Postgres offers no `IF NOT EXISTS` for, and the value\n    -- is read by a human with a debugger far more often than by this module.\n    authority     text   NOT NULL CHECK (authority IN (\'live\', \'rebuilding\'))\n);\n";
Expand description

The projection checkpoint, before its identifiers are filled in.