canonicalStatefunctionfunction canonicalState(state: State): unknownA state in the order that makes its hash: tables and columns by their words, constraints by what they are, identities and hints left out.
The state of a database (commons data 0011-sql-lifecycle FR-002): the written structure of its tables as a plain value, made from a logical schema bound to a dialect and a naming. It is addressed by its hash, so two states of the same structure are one state whatever order their tables were made in, and a state of another dialect or another naming is another state. What a person said of the past (renamedFrom) is a hint carried beside the structure and is not part of it.
canonicalStatefunctionfunction canonicalState(state: State): unknownA state in the order that makes its hash: tables and columns by their words, constraints by what they are, identities and hints left out.
emptyStateconstconst emptyState: (dialect: string, naming: { readonly names: string; readonly codes: string; }, qualifier?: string | undefined) => StateA state with no table, which an empty database is in.
| Parameter | What it is |
|---|---|
dialect | the dialect's name |
naming | the names of the case styles |
qualifier | the schema, where the dialect has schemas and one was given |
Returns: the empty state
Stateinterfaceinterface StateThe state of a database.
| Member | Type | What it is |
|---|---|---|
format | 1 | |
dialect | string | |
naming | { readonly names: string; readonly codes: string; } | |
qualifier? | string | The schema the tables are qualified by, where the dialect has schemas and one was given (0013-sql-qualified-names FR-006). |
tables | readonly StateTable[] |
StateColumninterfaceinterface StateColumnA column as written.
| Member | Type | What it is |
|---|---|---|
id | string | |
words | readonly string[] | The words of its name, which are what it is, whatever case style writes them. |
name | string | |
type | string | |
nullable | boolean | |
default? | string | |
renamedFrom? | readonly string[] | The words the column had, where governance says it was renamed. A hint: it is not part of the structure. |
StateConstraintinterfaceno test imports itinterface StateConstraintA foreign key, a unique, a check or an index as written; signature is what it is, apart from its name.
| Member | Type | What it is |
|---|---|---|
id | string | |
kind | "check" | "foreignKey" | "index" | "unique" | |
name | string | |
signature | string | |
text | string | The clause that makes it, as CREATE TABLE or ADD writes it. |
StateOptionsinterfaceno test imports itinterface StateOptionsWhat a state is made with.
| Member | Type | What it is |
|---|---|---|
dialect | Dialect | |
naming? | Naming | |
schema? | string | The schema the tables are in. |
tableClauses? | readonly TableClause[] | What extensions add to the end of a table; the lifecycle diffs them as part of the table. |
StateRowinterfaceno test imports itinterface StateRowA row of a code table as written.
| Member | Type | What it is |
|---|---|---|
code | string | |
label | string | |
description | string | null |
StateTableinterfaceinterface StateTableA table as written.
| Member | Type | What it is |
|---|---|---|
id | string | |
words | readonly string[] | |
name | string | |
columns | readonly StateColumn[] | |
primaryKey | readonly string[] | The written names of the primary key's columns, in order. |
constraints | readonly StateConstraint[] | |
rows | readonly StateRow[] | |
clause? | string | What an extension adds to the end of CREATE TABLE (a partition), as written. |
renamedFrom? | readonly string[] | The words the table had, where governance says it was renamed. A hint: it is not part of the structure. |
snapshotOffunctionfunction snapshotOf(schema: LogicalSchema, options: StateOptions): { readonly kind: "ok"; readonly value: State; } | { readonly kind: "err"; readonly error: readonly PhysicalError[]; }The state a logical schema leaves a database in.
| Parameter | What it is |
|---|---|
schema | the logical schema |
options | the dialect, the naming and the table clauses |
Returns: the state, or every error of writing it
stateHashconstconst stateHash: (state: State) => stringThe hash of a state: the SHA-256 of its canonical JSON.
| Parameter | What it is |
|---|---|
state | the state |
Returns: 64 hexadecimal digits