DDL

Constant DDL 

Source
pub const DDL: &str = "\
CREATE TABLE IF NOT EXISTS beck_log (
    seq   BIGSERIAL PRIMARY KEY,
    at    BIGINT      NOT NULL,
    actor TEXT        NOT NULL,
    body  BYTEA       NOT NULL
);
-- `seq` is append-only and therefore perfectly correlated with physical order, which is the one
-- case BRIN is built for: a summary per block range instead of a tuple per row. Every read this
-- store performs is `WHERE seq > $1 ORDER BY seq LIMIT $2`, so the index is scanned as a range and
-- never probed as a point. The primary key's btree stays because it enforces uniqueness; BRIN is
-- what the range scans use, and it is kilobytes where the btree is megabytes.
CREATE INDEX IF NOT EXISTS beck_log_seq_brin ON beck_log USING BRIN (seq);
CREATE TABLE IF NOT EXISTS beck_snapshot (
    seq   BIGINT PRIMARY KEY,
    state BYTEA  NOT NULL
);
-- The format the two tables above are written in. Checked on open, because a log read back under a
-- different encoding does not fail — it produces plausible nonsense, and an append-only audit trail
-- may not have that outcome (`beck_core::repr::FORMAT`).
CREATE TABLE IF NOT EXISTS beck_meta (
    id      INT PRIMARY KEY CHECK (id = 1),
    format  INT NOT NULL
);
";
Expand description

The DDL the compiler emits for a durable fold (§4.3 stage 4, “emit state artefacts”).