Skip to main content

MIGRATION_0001

Constant MIGRATION_0001 

Source
const MIGRATION_0001: &str = "-- Auth schema. Applied idempotently at startup (task S5).\n-- Raw tokens are never stored: token_hash = lowercase hex sha256(raw).\n-- ACCESS MODEL: no tiers. A credential holds grants; each grant names one\n-- package directory it may list/download. The `public` directory needs no\n-- credential and never appears in grants.\n\nCREATE TABLE IF NOT EXISTS tokens (\n    token_hash TEXT PRIMARY KEY,\n    label      TEXT,\n    created_at INTEGER NOT NULL,\n    expires_at INTEGER,           -- unix seconds; NULL = never\n    revoked    INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE IF NOT EXISTS grants (\n    token_hash TEXT NOT NULL REFERENCES tokens(token_hash) ON DELETE CASCADE,\n    directory  TEXT NOT NULL,     -- matches PackageInfo.directory ([a-z0-9_-]+)\n    PRIMARY KEY (token_hash, directory)\n);\n";
Expand description

Idempotent (IF NOT EXISTS), so it runs on every start.