applyChangefunctionfunction applyChange(state: State, change: Change): StateThe state a change leads to.
| Parameter | What it is |
|---|---|
state | the state before |
change | the change |
Returns: the state after
Changes (commons data 0011-sql-lifecycle FR-004, FR-005, FR-013): what differs between two states, found by the identity of each element (its words, and for a constraint what it is) and not by its written name, so that a change of case style is a rename and a change of what an element is called in governance is a rename where governance says so. applyChange is the state a change leads to; applying the changes of diff(a, b) to a reaches b, which is checked by the plan and by property tests.
applyChangefunctionfunction applyChange(state: State, change: Change): StateThe state a change leads to.
| Parameter | What it is |
|---|---|
state | the state before |
change | the change |
Returns: the state after
applyChangesconstconst applyChanges: (state: State, changes: readonly Change[]) => StateThe state that applying changes in order leads to.
| Parameter | What it is |
|---|---|
state | the state before; none for an empty database of the given dialect and naming |
changes | the changes |
Returns: the state after
Changetypeno test imports ittype Change =
| {
readonly kind: "renameTable";
readonly key: string;
readonly fromWords: readonly s… (2328 characters)type Change =
| {
readonly kind: "renameTable";
readonly key: string;
readonly fromWords: readonly string[];
readonly toWords: readonly string[];
readonly fromName: string;
readonly toName: string;
}
| { readonly kind: "renameColumn"; readonly key: string; readonly table: TableRef; readonly from: StateColumn; readonly to: StateColumn }
| { readonly kind: "dropConstraint"; readonly key: string; readonly table: TableRef; readonly constraint: StateConstraint }
| {
readonly kind: "renameConstraint";
readonly key: string;
readonly table: TableRef;
readonly from: StateConstraint;
readonly to: StateConstraint;
}
| { readonly kind: "addColumn"; readonly key: string; readonly table: TableRef; readonly column: StateColumn }
| { readonly kind: "dropColumn"; readonly key: string; readonly table: TableRef; readonly column: StateColumn }
| { readonly kind: "alterType"; readonly key: string; readonly table: TableRef; readonly from: StateColumn; readonly to: StateColumn }
| { readonly kind: "alterNullable"; readonly key: string; readonly table: TableRef; readonly from: StateColumn; readonly to: StateColumn }
| { readonly kind: "alterDefault"; readonly key: string; readonly table: TableRef; readonly from: StateColumn; readonly to: StateColumn }
| {
readonly kind: "alterPrimaryKey";
readonly key: string;
readonly table: TableRef;
readonly from: readonly string[];
readonly to: readonly string[];
}
| {
readonly kind: "alterClause";
readonly key: string;
readonly table: TableRef;
readonly from: string | undefined;
readonly to: string | undefined;
}
| { readonly kind: "createTable"; readonly key: string; readonly table: StateTable }
| { readonly kind: "addConstraint"; readonly key: string; readonly table: TableRef; readonly constraint: StateConstraint }
| {
readonly kind: "upsertRows";
readonly key: string;
readonly table: TableRef;
readonly rows: readonly StateRow[];
readonly before: readonly StateRow[];
}
| { readonly kind: "removeRows"; readonly key: string; readonly table: TableRef; readonly rows: readonly StateRow[] }
| { readonly kind: "dropTable"; readonly key: string; readonly table: StateTable };What a change is.
ChangeKindtypeno test imports ittype ChangeKind = Change["kind"];The kinds of change.
difffunctionfunction diff(from: State | undefined, to: State): readonly Change[]What differs between two states.
| Parameter | What it is |
|---|---|
from | the state a database is in; none for an empty database |
to | the state wanted |
Returns: the changes, in the order they are to be made: renames, drops of constraints, changes of columns, new tables, new constraints, rows, drops of tables
TableRefinterfaceno test imports itinterface TableRefA table as a change names it: its words and its written name at the moment the change is made.
| Member | Type | What it is |
|---|---|---|
words | readonly string[] | |
name | string |