IF Commons GitHub

governance/schema

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-sql-governance FR-003

The layout of the tables, as data a reader of the database can use without the library: what each table holds and what each column means, and the versions of the layout in order. The layout is the same in every dialect (a column is a text, an integer or bytes, and each dialect names the type its own way); a newer layout only adds, and a database of a newer layout than the library knows is refused and never changed.

import { LAYOUT, SCHEMA_VERSION } from "./schema.ts";
SCHEMA_VERSION; // 3
LAYOUT.filter((c) => c.table === "versions").map((c) => c.column); // ["id", "sum", "replica", "seq", "path", "parent", "merged", "kind", "blob"]

Source: commons/anyfs-sql/src/governance/schema.ts

4 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

SCHEMA_VERSIONconst
const SCHEMA_VERSION: 3

The version of the layout this library writes.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

LAYOUT_NAMEconst
const LAYOUT_NAME: "anyfs-sql-merge"

The name the layout has in the facts of a database: the version rows and the blobs of a store that merges.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

ColumnKindtypeno test imports it
type ColumnKind = "text" | "integer" | "bytes" | "tsvector";

What a column holds, in the words of every dialect.

Columntypeno test imports it
type Column = { readonly table: TableRole; readonly column: string; readonly kind: ColumnKind; readonly since: number; readonly means: string };

One column of the layout: the table, its name, what it holds and what it means.

LAYOUTconst
const LAYOUT: readonly Column[]

The columns of every table and view, in order: the documented layout. A catalog reads these and no other.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

MIGRATION_PLANconst
const MIGRATION_PLAN: readonly { readonly version: number; readonly name: string; readonly destructive: boolean; }[]

What a version of the layout adds, in order: the plan of the migrations. The version rows are the only layout there is: a database of an earlier layout is not migrated and is refused.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.