qubu 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/diff.mjs +1 -1
- package/docs/migrations/index.md +31 -0
- package/docs/schema/ddl-emission.md +20 -0
- package/package.json +1 -1
package/dist/diff.mjs
CHANGED
|
@@ -518,7 +518,7 @@ function addInternalObject(records, kind, value, path, namespace, parent, snapsh
|
|
|
518
518
|
function operationForMatch(match, diagnostics) {
|
|
519
519
|
const before = match.before.object;
|
|
520
520
|
const after = match.after.object;
|
|
521
|
-
const changedProperties = propertyChangesBetween(before.value, after.value);
|
|
521
|
+
const changedProperties = propertyChangesBetween(before.value, after.value).filter((change) => !(before.kind === "column" && change.path.length === 1 && change.path[0] === "ordinalPosition"));
|
|
522
522
|
const physicalRename = before.physicalName !== void 0 && after.physicalName !== void 0 && before.physicalName !== after.physicalName;
|
|
523
523
|
const blockedRename = match.before.lossy || match.after.lossy;
|
|
524
524
|
const effectiveChanges = physicalRename && blockedRename && changedProperties.length === 0 ? freeze([{
|
package/docs/migrations/index.md
CHANGED
|
@@ -91,3 +91,34 @@ import { emitMigrationPlan } from "@qubu/migrate/ddl/postgres"
|
|
|
91
91
|
|
|
92
92
|
const preview = emitMigrationPlan(plan)
|
|
93
93
|
```
|
|
94
|
+
|
|
95
|
+
## Column order
|
|
96
|
+
|
|
97
|
+
Migration generation defaults to declaration order. PostgreSQL can opt in to
|
|
98
|
+
alignment ordering for new tables:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { compileMigrationProgram } from "@qubu/migrate/artifact/postgres"
|
|
102
|
+
|
|
103
|
+
const compiled = compileMigrationProgram(plan, { columnOrder: "alignment" })
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For the CLI, add `columnOrder: "alignment"` to your existing `qubu.config.js`.
|
|
107
|
+
Both generation commands also accept an override:
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
qubu migrate create add-users --column-order alignment
|
|
111
|
+
qubu schema bootstrap --column-order alignment --dry-run
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The flag overrides configuration; omitting both selects `"declaration"`. Use
|
|
115
|
+
`--column-order declaration` to override an alignment setting. MySQL and SQLite
|
|
116
|
+
reject alignment ordering. `qubu migrate apply` executes the sealed program;
|
|
117
|
+
changing configuration does not change an existing artifact.
|
|
118
|
+
|
|
119
|
+
Alignment ordering is a conservative PostgreSQL storage heuristic, not a guarantee
|
|
120
|
+
of smaller rows. Known fixed-width columns come first, sorted by descending
|
|
121
|
+
alignment with stable ties. Variable-length and unknown types follow in declaration
|
|
122
|
+
order. Existing tables are never automatically repacked, and column-order-only
|
|
123
|
+
snapshot differences do not generate migrations. Sealing retains existing physical
|
|
124
|
+
column ordinals and records the selected order for new tables.
|
|
@@ -89,3 +89,23 @@ For execution, compile the plan with `compileMigrationProgram()` from
|
|
|
89
89
|
`@qubu/migrate/artifact`. The versioned program—not the aggregate `sql`
|
|
90
90
|
string—is authoritative. See [Artifacts and approval
|
|
91
91
|
policy](../migrations/artifacts-and-policy.md).
|
|
92
|
+
|
|
93
|
+
CREATE TABLE statements follow column `ordinalPosition` values, preserving schema
|
|
94
|
+
declaration order across PostgreSQL, MySQL, and SQLite. Snapshot arrays remain
|
|
95
|
+
sorted by ID for deterministic serialization; array order does not determine DDL
|
|
96
|
+
column order.
|
|
97
|
+
|
|
98
|
+
For new PostgreSQL tables, opt in to alignment ordering:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { emitMigrationPlan } from "@qubu/migrate/ddl/postgres"
|
|
102
|
+
|
|
103
|
+
const preview = emitMigrationPlan(plan, { columnOrder: "alignment" })
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The default is `"declaration"`. Alignment ordering places known fixed-width types
|
|
107
|
+
first, in descending alignment order, preserving declaration order for ties.
|
|
108
|
+
Variable-length and unknown types retain their relative order after that group.
|
|
109
|
+
This is a conservative heuristic: nulls and variable-length values affect actual
|
|
110
|
+
savings. It does not rebuild or reorder existing tables or change index key order.
|
|
111
|
+
MySQL and SQLite reject `"alignment"`.
|