qubu 0.5.1 → 0.6.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/README.md +112 -0
- package/dist/codegen.d.mts +1 -1
- package/dist/codegen.mjs +1 -1
- package/dist/column-BzN8KFJa.mjs +364 -0
- package/dist/column-CFvSbil0.mjs +309 -0
- package/dist/{complete-types-CY0KbzNw.d.mts → complete-types-CNMWBWap.d.mts} +1 -1
- package/dist/constraints-DM_tarXc.mjs +208 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +2 -3
- package/dist/diagnostics-I9vVtXkc.mjs +40 -0
- package/dist/diff.d.mts +2 -2
- package/dist/expressions-BCjc08zw.mjs +129 -0
- package/dist/index-CGui70hi.d.mts +32 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +58 -13
- package/dist/introspection/mysql.d.mts +26 -0
- package/dist/introspection/mysql.mjs +1145 -0
- package/dist/introspection/postgres.d.mts +40 -0
- package/dist/introspection/postgres.mjs +1554 -0
- package/dist/introspection/sqlite.d.mts +15 -0
- package/dist/introspection/sqlite.mjs +986 -0
- package/dist/introspection.d.mts +3 -78
- package/dist/introspection.mjs +5 -3683
- package/dist/mysql.d.mts +1 -1
- package/dist/mysql.mjs +2 -2
- package/dist/{on-conflict-jPsl9l0K.mjs → on-conflict-CnaY5qso.mjs} +76 -3
- package/dist/postgres-Dey7QXPL.mjs +69 -0
- package/dist/postgres.d.mts +3 -3
- package/dist/postgres.mjs +3 -52
- package/dist/registry-oWDiqD7i.mjs +127 -0
- package/dist/{relational-x3BDVX9e.mjs → relational-DSAJ-l58.mjs} +1 -2
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +7 -4
- package/dist/{sqlite-CsIUtZ2Q.mjs → serialize-CE-gw5_s.mjs} +4 -318
- package/dist/serialize-OvXCLzjm.d.mts +66 -0
- package/dist/snapshot/mysql.d.mts +17 -0
- package/dist/snapshot/mysql.mjs +356 -0
- package/dist/snapshot/postgres.d.mts +17 -0
- package/dist/snapshot/postgres.mjs +237 -0
- package/dist/snapshot/sqlite.d.mts +25 -0
- package/dist/snapshot/sqlite.mjs +321 -0
- package/dist/{snapshot-BSraiLtH.mjs → snapshot-DgsOhf_8.mjs} +4 -42
- package/dist/snapshot.d.mts +5 -4
- package/dist/snapshot.mjs +2 -583
- package/dist/{source-C4Vmu5bb.mjs → source-BDuUXmAk.mjs} +2 -1
- package/dist/sqlite.d.mts +1 -1
- package/dist/sqlite.mjs +6 -6
- package/dist/{table-DLQ7YWth.mjs → table-C1QGNe4P.mjs} +3 -2
- package/dist/{types-CTCqtFlS.d.mts → types-BEn0N_al.d.mts} +1 -1
- package/dist/{types-CTENnDh9.mjs → types-BLNRatG_.mjs} +2 -3
- package/dist/{types-C0VkiwpR.d.mts → types-DUe6eeI0.d.mts} +57 -28
- package/docs/guides/compose-queries.md +22 -0
- package/docs/guides/drizzle.md +11 -11
- package/docs/guides/mutations.md +89 -0
- package/docs/guides/valtio-sync.md +113 -0
- package/docs/migrations/index.md +57 -19
- package/docs/migrations/operations.md +20 -6
- package/docs/reference/mysql-snapshot.md +5 -5
- package/docs/reference/postgres-snapshot.md +7 -7
- package/docs/reference/sqlite-snapshot.md +5 -5
- package/docs/reference/supported-surface.md +20 -6
- package/docs/schema/code-generation.md +5 -4
- package/docs/schema/ddl-emission.md +1 -1
- package/docs/schema/introspection.md +3 -2
- package/docs/schema/snapshots.md +12 -0
- package/docs/sql-semantic-types.md +8 -0
- package/package.json +25 -1
- package/dist/column-DmazTL67.mjs +0 -633
- package/dist/index-C-480HmV.d.mts +0 -146
- package/dist/registry-BGqa05et.mjs +0 -461
- package/dist/standard-DfcZEVOj.mjs +0 -12
- package/dist/value-BEEj_Ayd.mjs +0 -29
package/docs/migrations/index.md
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
Qubu migrations are split across explicit ownership boundaries:
|
|
6
6
|
|
|
7
|
-
| Owner | Imports
|
|
8
|
-
| --------------- |
|
|
9
|
-
| `qubu` | `qubu/snapshot`, `qubu/diff`, `qubu/introspection` | Pure schema snapshots, comparison, and catalog mapping |
|
|
10
|
-
| `@qubu/migrate` | Focused subpaths listed below
|
|
11
|
-
| `@qubu/cli` | `@qubu/cli/config`, `@qubu/cli/repository`
|
|
12
|
-
| Adapter package | `@qubu/adapter-*/migration`
|
|
13
|
-
| Application | Its own configuration and deployment code
|
|
7
|
+
| Owner | Imports | Responsibility |
|
|
8
|
+
| --------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `qubu` | `qubu/snapshot`, `qubu/snapshot/postgres`, `qubu/snapshot/sqlite`, `qubu/snapshot/mysql`, `qubu/diff`, `qubu/introspection` | Pure schema snapshots, comparison, and catalog mapping |
|
|
10
|
+
| `@qubu/migrate` | Focused subpaths listed below | Pure planning and compilation plus portable artifacts, journals, execution, status, baselines, and bootstrap |
|
|
11
|
+
| `@qubu/cli` | `@qubu/cli/config`, `@qubu/cli/repository` | Node.js configuration loading, artifact files, commands, output, and process exit behavior |
|
|
12
|
+
| Adapter package | `@qubu/adapter-*/migration` | Pinned driver sessions, parameter binding, transactions, leases, locks, database journal storage, and failure classification |
|
|
13
|
+
| Application | Its own configuration and deployment code | Credentials, environment selection, approval policy, custom SQL, rollout timing, and legacy cutover decisions |
|
|
14
14
|
|
|
15
15
|
The pre-alpha `qubu/migration` and `qubu/ddl` entrypoints no longer exist. Use
|
|
16
16
|
the extracted compiler entrypoints:
|
|
@@ -25,18 +25,26 @@ The `@qubu/migrate` root intentionally exports only format/version constants
|
|
|
25
25
|
and the central plan and artifact types. Import behavior from its focused
|
|
26
26
|
entrypoint:
|
|
27
27
|
|
|
28
|
-
| Entrypoint
|
|
29
|
-
|
|
|
30
|
-
| `@qubu/migrate/plan`
|
|
31
|
-
| `@qubu/migrate/ddl`
|
|
32
|
-
| `@qubu/migrate/
|
|
33
|
-
| `@qubu/migrate/
|
|
34
|
-
| `@qubu/migrate/
|
|
35
|
-
| `@qubu/migrate/
|
|
36
|
-
| `@qubu/migrate/
|
|
37
|
-
| `@qubu/migrate/
|
|
38
|
-
| `@qubu/migrate/
|
|
39
|
-
| `@qubu/migrate/
|
|
28
|
+
| Entrypoint | Use it for |
|
|
29
|
+
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
30
|
+
| `@qubu/migrate/plan` | Create, encode, decode, fingerprint, and validate migration plans |
|
|
31
|
+
| `@qubu/migrate/ddl` | Preview deterministic dialect SQL without opening a database |
|
|
32
|
+
| `@qubu/migrate/ddl/postgres` | Preview PostgreSQL SQL from an approved migration plan |
|
|
33
|
+
| `@qubu/migrate/ddl/sqlite` | Preview SQLite SQL from an approved migration plan |
|
|
34
|
+
| `@qubu/migrate/ddl/mysql` | Preview MySQL SQL from an approved migration plan |
|
|
35
|
+
| `@qubu/migrate/artifact` | Compile programs with a caller-supplied `SchemaDialect`; canonicalize, digest, seal, encode, and decode artifacts |
|
|
36
|
+
| `@qubu/migrate/artifact/postgres` | Compile reviewed plans with PostgreSQL's schema dialect |
|
|
37
|
+
| `@qubu/migrate/artifact/sqlite` | Compile reviewed plans with SQLite's schema dialect, including table rebuilds |
|
|
38
|
+
| `@qubu/migrate/artifact/mysql` | Compile reviewed plans with MySQL's schema dialect |
|
|
39
|
+
| `@qubu/migrate/repository` | Verify a complete artifact chain and its journal prefix |
|
|
40
|
+
| `@qubu/migrate/journal` | Implement or inspect the storage-neutral journal contract |
|
|
41
|
+
| `@qubu/migrate/executor` | Apply artifacts and reconcile uncertain attempts |
|
|
42
|
+
| `@qubu/migrate/baseline` | Verify and record the initial non-executable baseline |
|
|
43
|
+
| `@qubu/migrate/status` | Inspect pending work, drift, requirements, and interrupted attempts |
|
|
44
|
+
| `@qubu/migrate/bootstrap` | Prepare a fresh schema diff and expose shared bootstrap types; accepts a caller-supplied `SchemaDialect` for generic planning |
|
|
45
|
+
| `@qubu/migrate/bootstrap/postgres` | Plan a fresh PostgreSQL schema through the normal compiler |
|
|
46
|
+
| `@qubu/migrate/bootstrap/sqlite` | Plan a fresh SQLite schema through the normal compiler |
|
|
47
|
+
| `@qubu/migrate/testing` | Test adapter capabilities and deterministic failure boundaries |
|
|
40
48
|
|
|
41
49
|
Start with [Artifacts and approval policy](artifacts-and-policy.md) when
|
|
42
50
|
reviewing a migration format. Check [Adapter capability
|
|
@@ -44,3 +52,33 @@ profiles](adapters.md), use [Command line operations](operations.md) to
|
|
|
44
52
|
configure an application, then keep [Recovery and reconciliation](recovery.md)
|
|
45
53
|
with the deployment runbook. [Lotta Games adoption](lotta-adoption.md) records
|
|
46
54
|
the downstream cutover boundary and current combo-matrix blocker.
|
|
55
|
+
|
|
56
|
+
Choose the dialect-specific bootstrap entrypoint when using a built-in dialect:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { planSchemaBootstrap } from "@qubu/migrate/bootstrap/postgres"
|
|
60
|
+
|
|
61
|
+
const result = planSchemaBootstrap(targetSnapshot)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The neutral `@qubu/migrate/bootstrap` entrypoint contains the shared preparation
|
|
65
|
+
logic and generic planner. The PostgreSQL and SQLite entrypoints each import
|
|
66
|
+
only their matching schema dialect.
|
|
67
|
+
|
|
68
|
+
Use the same entrypoint pattern for convenience artifact compilers:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { compileMigrationProgram } from "@qubu/migrate/artifact/postgres"
|
|
72
|
+
|
|
73
|
+
const compiled = compileMigrationProgram(plan)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The DDL entrypoints follow the same pattern. Use the neutral entrypoint when
|
|
77
|
+
the application supplies a `SchemaDialect`; use a dialect subpath when the
|
|
78
|
+
built-in dialect should be selected by the module:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { emitMigrationPlan } from "@qubu/migrate/ddl/postgres"
|
|
82
|
+
|
|
83
|
+
const preview = emitMigrationPlan(plan)
|
|
84
|
+
```
|
|
@@ -70,7 +70,7 @@ working directory.
|
|
|
70
70
|
| `qubu migrate apply [--dry-run]` | Applies the complete verified pending chain; dry-run performs status/preflight only | It never limits discovery to Git-added or branch-diff files |
|
|
71
71
|
| `qubu migrate baseline <id> --confirm <fact>... [--dry-run]` | Without dry-run, strictly compares the live managed schema, initializes an empty journal, records baseline, then writes the artifact | Requires an empty artifact repository and all seven exact confirmations; dry-run does not inspect the database |
|
|
72
72
|
| `qubu migrate reconcile <attempt-id> --outcome applied\|rolled_back --reason <text>` | Runs application-owned verification, then records the explicit outcome | Requires `verifyReconciliation` in config; no automatic inference |
|
|
73
|
-
| `qubu schema bootstrap [--approve <operation-id=reason>...] [--dry-run]` | Plans an empty SQLite snapshot through diff/plan/program; executes through the normal executor unless dry-run
|
|
73
|
+
| `qubu schema bootstrap [--approve <operation-id=reason>...] [--dry-run]` | Plans an empty SQLite or PostgreSQL snapshot through diff/plan/program; executes through the normal executor unless dry-run | Rejects other dialects; unsafe or incomplete facts still require exact approvals or custom programs |
|
|
74
74
|
|
|
75
75
|
JSON output is stable, newline-terminated, recursively key-sorted, and redacts
|
|
76
76
|
credential-like keys and credentials or secrets embedded in URLs. Human output
|
|
@@ -94,11 +94,25 @@ snapshot. Logical IDs help reporting but do not prove equality. Objects not
|
|
|
94
94
|
owned by the managed snapshot are returned separately as `unmanagedObjects`;
|
|
95
95
|
Qubu journal objects are excluded by migration snapshot readers.
|
|
96
96
|
|
|
97
|
-
`schema bootstrap` is for a fresh SQLite database
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
`schema bootstrap` is for a fresh SQLite database or a fresh PostgreSQL schema.
|
|
98
|
+
It produces the same reviewed plan, versioned program, sealed artifact, and
|
|
99
|
+
executor path as a migration. A complete PostgreSQL snapshot retains standalone
|
|
100
|
+
enums as authoritative objects; bootstrap creates each enum before a table that
|
|
101
|
+
uses it as a native column type. SQLite inline constraints are compiled into
|
|
102
|
+
table creation, while table rebuilds are explicit phases with copy/postcondition
|
|
103
|
+
checks. Session settings such as SQLite PRAGMAs remain in the application or
|
|
104
|
+
adapter setup.
|
|
105
|
+
|
|
106
|
+
Use the reviewed complete snapshot directly as the PostgreSQL target:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
qubu schema bootstrap --dry-run --format json --non-interactive
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The dry run prints the ordered phases without opening the adapter. Remove
|
|
113
|
+
`--dry-run` only after reviewing any operation IDs that require `--approve` or
|
|
114
|
+
an application-owned custom program. Bootstrap does not import or replay
|
|
115
|
+
Drizzle migration history.
|
|
102
116
|
|
|
103
117
|
## Baseline and cutover checklist
|
|
104
118
|
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
> MySQL facts Qubu v1 can encode and the combinations that need a later server
|
|
5
5
|
> version or engine policy.
|
|
6
6
|
|
|
7
|
-
Import the adapter from the
|
|
7
|
+
Import the adapter from the MySQL snapshot subpath:
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
import {
|
|
10
|
+
import { createSchemaSnapshot, tryCreateSchemaSnapshot } from "qubu/snapshot/mysql"
|
|
11
11
|
|
|
12
|
-
const snapshot =
|
|
13
|
-
const result =
|
|
12
|
+
const snapshot = createSchemaSnapshot(appSchema)
|
|
13
|
+
const result = tryCreateSchemaSnapshot(appSchema)
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The snapshot dialect is named `mysql`, the same name used by Qubu's query
|
|
@@ -38,7 +38,7 @@ Capability checks run before common traversal. Use the non-throwing form when
|
|
|
38
38
|
a schema may include a MySQL engine or version-specific feature:
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
const result =
|
|
41
|
+
const result = tryCreateSchemaSnapshot(appSchema)
|
|
42
42
|
if (!result.ok) {
|
|
43
43
|
for (const issue of result.diagnostics) {
|
|
44
44
|
console.error(issue.path.join("."), issue.code, issue.message)
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
> PostgreSQL facts Qubu v1 can encode and the cases that need a later server
|
|
5
5
|
> version policy.
|
|
6
6
|
|
|
7
|
-
Import the adapter from the
|
|
7
|
+
Import the adapter from the PostgreSQL snapshot subpath:
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
+
import { createSchemaSnapshot } from "qubu/snapshot"
|
|
10
11
|
import {
|
|
11
|
-
createSchemaSnapshot,
|
|
12
|
-
createPostgresSchemaSnapshot,
|
|
12
|
+
createSchemaSnapshot as createPostgresSnapshot,
|
|
13
13
|
postgresSnapshotAdapter,
|
|
14
|
-
} from "qubu/snapshot"
|
|
14
|
+
} from "qubu/snapshot/postgres"
|
|
15
15
|
|
|
16
|
-
const snapshot =
|
|
16
|
+
const snapshot = createPostgresSnapshot(appSchema)
|
|
17
17
|
// Equivalent: createSchemaSnapshot(appSchema, { adapter: postgresSnapshotAdapter })
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -46,9 +46,9 @@ schema and application boundaries.
|
|
|
46
46
|
Use the non-throwing form when a schema may contain a server-specific feature:
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
|
-
import {
|
|
49
|
+
import { tryCreateSchemaSnapshot } from "qubu/snapshot/postgres"
|
|
50
50
|
|
|
51
|
-
const result =
|
|
51
|
+
const result = tryCreateSchemaSnapshot(appSchema)
|
|
52
52
|
if (!result.ok) {
|
|
53
53
|
for (const issue of result.diagnostics) {
|
|
54
54
|
console.error(issue.path.join("."), issue.code, issue.message)
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> Use this matrix to decide which SQLite schema facts Qubu v1 can serialize and which combinations must be diagnosed before a snapshot is written.
|
|
4
4
|
|
|
5
|
-
Import the adapter from the
|
|
5
|
+
Import the adapter from the SQLite snapshot subpath:
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import {
|
|
8
|
+
import { createSchemaSnapshot, tryCreateSchemaSnapshot } from "qubu/snapshot/sqlite"
|
|
9
9
|
|
|
10
|
-
const snapshot =
|
|
11
|
-
const result =
|
|
10
|
+
const snapshot = createSchemaSnapshot(appSchema)
|
|
11
|
+
const result = tryCreateSchemaSnapshot(appSchema)
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
The snapshot dialect is `sqlite`, the same name used by Qubu's query dialect.
|
|
@@ -36,7 +36,7 @@ Capability checks run before common traversal. Use the non-throwing form when a
|
|
|
36
36
|
schema may include a feature that depends on a SQLite version or table shape:
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
const result =
|
|
39
|
+
const result = tryCreateSchemaSnapshot(appSchema)
|
|
40
40
|
if (!result.ok) {
|
|
41
41
|
for (const issue of result.diagnostics) {
|
|
42
42
|
console.error(issue.path.join("."), issue.code, issue.message)
|
|
@@ -10,24 +10,38 @@
|
|
|
10
10
|
| `qubu/core` | Runtime | Fragment and rendering primitives, dialect construction, SQL types, and extension constructors |
|
|
11
11
|
| `qubu/codegen` | Runtime | Deterministic machine-owned TypeScript schemas from complete, non-lossy introspection |
|
|
12
12
|
| `qubu/diff` | Runtime | Canonical Snapshot v1 or v2 comparison, rename hints, suggestions, and safety diagnostics |
|
|
13
|
-
| `qubu/introspection` | Runtime |
|
|
13
|
+
| `qubu/introspection` | Runtime | Shared catalog contracts, normalized catalog models, diagnostics, and mapping to Snapshot v1 or v2 |
|
|
14
|
+
| `qubu/introspection/postgres` | Runtime | PostgreSQL catalog reader and catalog queries for one selected namespace |
|
|
15
|
+
| `qubu/introspection/sqlite` | Runtime | SQLite catalog reader and catalog queries for one selected namespace |
|
|
16
|
+
| `qubu/introspection/mysql` | Runtime | MySQL catalog reader and catalog queries for one selected namespace |
|
|
14
17
|
| `qubu/mysql` | Runtime | The MySQL query dialect policy |
|
|
15
18
|
| `qubu/postgres` | Runtime | PostgreSQL query dialect helpers such as `postgresDialect()` and `ilike()` |
|
|
16
19
|
| `qubu/schema` | Runtime | Advanced schema metadata, storage and constraint models, source models, and schema-expression extensions |
|
|
17
20
|
| `qubu/snapshot` | Runtime | Canonical Snapshot v1 and v2 traversal, encoding, decoding, diagnostics, and fingerprints |
|
|
21
|
+
| `qubu/snapshot/mysql` | Runtime | MySQL snapshot adapter, schema dialect, and convenience creators |
|
|
22
|
+
| `qubu/snapshot/postgres` | Runtime | PostgreSQL snapshot adapter, schema dialect, and convenience creators |
|
|
23
|
+
| `qubu/snapshot/sqlite` | Runtime | SQLite snapshot adapter, schema dialect, affinity helper, and convenience creators |
|
|
18
24
|
| `qubu/sqlite` | Runtime | The SQLite query dialect policy and native SQLite column factories |
|
|
19
25
|
| `qubu/vite` | Runtime | The optional `qubu()` Vite compiler hint |
|
|
20
26
|
| `qubu/package.json` | JSON | The published package manifest |
|
|
21
27
|
| `@qubu/migrate` | Runtime | Migration compiler format identity and shared plan types |
|
|
22
28
|
| `@qubu/migrate/plan` | Runtime | Pure migration planning with dependencies, decisions, preconditions, and explicit custom SQL |
|
|
23
|
-
| `@qubu/migrate/ddl` | Runtime | DDL preflight and
|
|
24
|
-
| `@qubu/migrate/
|
|
29
|
+
| `@qubu/migrate/ddl` | Runtime | DDL preflight and generic emission from a migration plan and supplied schema dialect |
|
|
30
|
+
| `@qubu/migrate/ddl/postgres` | Runtime | PostgreSQL DDL emission from an approved migration plan |
|
|
31
|
+
| `@qubu/migrate/ddl/sqlite` | Runtime | SQLite DDL emission from an approved migration plan |
|
|
32
|
+
| `@qubu/migrate/ddl/mysql` | Runtime | MySQL DDL emission from an approved migration plan |
|
|
33
|
+
| `@qubu/migrate/artifact` | Runtime | Generic versioned program compilation with a caller-supplied schema dialect, plus strict artifacts and baselines |
|
|
34
|
+
| `@qubu/migrate/artifact/postgres` | Runtime | PostgreSQL versioned program compilation |
|
|
35
|
+
| `@qubu/migrate/artifact/sqlite` | Runtime | SQLite versioned program compilation, including table rebuilds |
|
|
36
|
+
| `@qubu/migrate/artifact/mysql` | Runtime | MySQL versioned program compilation |
|
|
25
37
|
| `@qubu/migrate/repository` | Runtime | Strict full-chain and journal-prefix verification |
|
|
26
38
|
| `@qubu/migrate/journal` | Runtime | Storage-neutral journal records, transitions, validation, and reference storage |
|
|
27
39
|
| `@qubu/migrate/executor` | Runtime | Portable execution, structured errors, checkpointing, and explicit reconciliation |
|
|
28
40
|
| `@qubu/migrate/baseline` | Runtime | Strict live baseline verification and physical managed-schema comparison |
|
|
29
41
|
| `@qubu/migrate/status` | Runtime | Pending chain, managed drift, unmanaged objects, interrupted attempts, and incompatible requirements |
|
|
30
|
-
| `@qubu/migrate/bootstrap` | Runtime |
|
|
42
|
+
| `@qubu/migrate/bootstrap` | Runtime | Shared bootstrap preparation, result types, and generic planning with a caller-supplied schema dialect |
|
|
43
|
+
| `@qubu/migrate/bootstrap/postgres` | Runtime | Fresh PostgreSQL schema planning through the normal diff, plan, and program compiler |
|
|
44
|
+
| `@qubu/migrate/bootstrap/sqlite` | Runtime | Fresh SQLite schema planning through the normal diff, plan, and program compiler |
|
|
31
45
|
| `@qubu/migrate/testing` | Runtime | Deterministic fake adapters, fault boundaries, and adapter conformance checks |
|
|
32
46
|
| `@qubu/cli` | Runtime and CLI | `@alloc/cmd-ts` commands, typed config, filesystem repositories, stable output, and exit codes |
|
|
33
47
|
| `@qubu/drizzle` | Runtime | Shared Drizzle conversion errors and dialect types |
|
|
@@ -66,7 +80,7 @@ entrypoint table.
|
|
|
66
80
|
| Read queries | Named projections, spreadable source columns, aliases, joins, typed custom and LATERAL `FROM` sources, correlated subqueries, `WHERE`, grouping with declared-key proofs, `HAVING`, ordering, window expressions, distinctness, pagination, row locking, ordinary and recursive CTEs, subqueries, and set operations |
|
|
67
81
|
| Expressions | Comparison, boolean, arithmetic, null, range, membership, aggregate, window, string, JSON scalar reads, definition-backed and raw casts, cases, parameterized SQL templates, custom expressions, and branded deterministic schema expressions |
|
|
68
82
|
| SQL type metadata | Portable domains and capabilities, physical column storage descriptors, `SqlTypeOf`, projected SQL type maps, `SourceLike` and `TableLike` field constraints, contextual literals, typed extension values, calls, and casts, plus a permissive `SqlUnknown` fallback |
|
|
69
|
-
| Write queries | `INSERT` values, defaults, and selects; `UPDATE
|
|
83
|
+
| Write queries | `INSERT` values, defaults, and selects; typed `UPDATE`, PostgreSQL `UPDATE ... FROM`, and `DELETE`; typed assignments; `RETURNING`; and explicit unrestricted-write opt-in |
|
|
70
84
|
| Rendering | Standard, PostgreSQL, SQLite, MySQL, and user-created policies for identifiers, placeholders, pagination, row locking, JSON, logical cast targets, schema literals, and EXPLAIN options |
|
|
71
85
|
| Execution boundary | `QueryAdapter`, opt-in `ExplainableQueryAdapter`, `StreamingQueryAdapter`, and `TransactionalQueryAdapter` capabilities, bound clients from `qubu()`, structured results from `execute()` or `db.execute()`, row-only results from `executeRows()` or `db.rows()`, typed read streams from `stream()` or `db.stream()`, and adapter-decoded plan rows from `explain()` or `db.explain()` |
|
|
72
86
|
| Snapshots | Pure Snapshot v1 and v2 creation, canonical encoding and strict decoding, immutable data, diagnostics, and FNV change-detection fingerprints |
|
|
@@ -74,7 +88,7 @@ entrypoint table.
|
|
|
74
88
|
| Snapshot diffing | Pure Snapshot v1 and v2 comparison, explicit rename evidence, non-authoritative suggestions, and safety diagnostics |
|
|
75
89
|
| Migration planning | Pure, dialect-neutral plans with stable ordering, dependency edges, preconditions, explicit review decisions, and tagged custom SQL |
|
|
76
90
|
| DDL emission | Preflight plus deterministic PostgreSQL, SQLite, and MySQL statements from an approved `MigrationPlan` and matching `SchemaDialect` |
|
|
77
|
-
| Migration operations | Strict artifacts and baselines, authoritative programs, repository and journal validation, adapter capability preflight, execution, status/drift, reconciliation, and
|
|
91
|
+
| Migration operations | Strict artifacts and baselines, authoritative programs, repository and journal validation, adapter capability preflight, execution, status/drift, reconciliation, SQLite bootstrap, and complete PostgreSQL bootstrap with standalone enum ordering |
|
|
78
92
|
| Build tooling | The optional Vite directive transform and its matching TypeScript ambient declarations |
|
|
79
93
|
| Drizzle conversion | Optional, dialect-specific runtime conversion from Qubu schema registries to Drizzle tables |
|
|
80
94
|
| Source generation | Pure Snapshot v1 table source printing, deterministic camelCase IDs, exact physical metadata, controlled type mappings, and structured failure diagnostics |
|
|
@@ -14,9 +14,10 @@ generator:
|
|
|
14
14
|
```ts
|
|
15
15
|
import { writeFile } from "node:fs/promises"
|
|
16
16
|
import { generateSchemaSource } from "qubu/codegen"
|
|
17
|
-
import { mapCatalogToSnapshot
|
|
17
|
+
import { mapCatalogToSnapshot } from "qubu/introspection"
|
|
18
|
+
import { readCatalog } from "qubu/introspection/sqlite"
|
|
18
19
|
|
|
19
|
-
const catalog = await
|
|
20
|
+
const catalog = await readCatalog(connection, { namespace: "main" })
|
|
20
21
|
const introspection = mapCatalogToSnapshot(catalog, { namespace: "main" })
|
|
21
22
|
const generated = generateSchemaSource(introspection)
|
|
22
23
|
|
|
@@ -49,10 +50,10 @@ baseline for the next catalog read:
|
|
|
49
50
|
|
|
50
51
|
```ts
|
|
51
52
|
import { mapCatalogToSnapshot } from "qubu/introspection"
|
|
52
|
-
import {
|
|
53
|
+
import { createSchemaSnapshot } from "qubu/snapshot/sqlite"
|
|
53
54
|
import { mainSchema } from "./schema.generated.ts"
|
|
54
55
|
|
|
55
|
-
const previousSnapshot =
|
|
56
|
+
const previousSnapshot = createSchemaSnapshot(mainSchema)
|
|
56
57
|
const next = mapCatalogToSnapshot(nextCatalog, {
|
|
57
58
|
namespace: "main",
|
|
58
59
|
previousSnapshot,
|
|
@@ -9,7 +9,7 @@ plan returns diagnostics and no SQL.
|
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
11
|
import { emitMigrationPlan } from "@qubu/migrate/ddl"
|
|
12
|
-
import { postgresSchemaDialect } from "qubu/snapshot"
|
|
12
|
+
import { postgresSchemaDialect } from "qubu/snapshot/postgres"
|
|
13
13
|
|
|
14
14
|
const result = emitMigrationPlan(plan, postgresSchemaDialect)
|
|
15
15
|
if (!result.ok) {
|
|
@@ -59,9 +59,10 @@ catalog can later support inspection, source generation, or another snapshot
|
|
|
59
59
|
format:
|
|
60
60
|
|
|
61
61
|
```ts
|
|
62
|
-
import { mapCatalogToSnapshot
|
|
62
|
+
import { mapCatalogToSnapshot } from "qubu/introspection"
|
|
63
|
+
import { readCatalog } from "qubu/introspection/sqlite"
|
|
63
64
|
|
|
64
|
-
const catalog = await
|
|
65
|
+
const catalog = await readCatalog(connection, { namespace: "main" })
|
|
65
66
|
const result = mapCatalogToSnapshot(catalog, {
|
|
66
67
|
namespace: "main",
|
|
67
68
|
mode: "strict",
|
package/docs/schema/snapshots.md
CHANGED
|
@@ -65,6 +65,18 @@ envelope. A dialect adapter owns physical storage mapping, SQL literal and
|
|
|
65
65
|
expression encoding, dialect extensions, capability checks, and any dialect
|
|
66
66
|
naming policy. PostgreSQL, SQLite, and MySQL adapters can implement
|
|
67
67
|
`SchemaSnapshotAdapter` without duplicating traversal or decoder rules.
|
|
68
|
+
The neutral API stays at `qubu/snapshot`; built-in dialect adapters have
|
|
69
|
+
dedicated subpaths so importing neutral snapshot utilities does not widen that
|
|
70
|
+
API:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { createSchemaSnapshot } from "qubu/snapshot"
|
|
74
|
+
import { createSchemaSnapshot as createPostgresSnapshot } from "qubu/snapshot/postgres"
|
|
75
|
+
|
|
76
|
+
const neutral = createSchemaSnapshot(appSchema)
|
|
77
|
+
const postgres = createPostgresSnapshot(appSchema)
|
|
78
|
+
```
|
|
79
|
+
|
|
68
80
|
The PostgreSQL adapter is documented in the [PostgreSQL snapshot support
|
|
69
81
|
matrix](../reference/postgres-snapshot.md). Its schema dialect extends the
|
|
70
82
|
`postgresql` query dialect, and snapshot metadata uses that same identity.
|
|
@@ -89,6 +89,14 @@ operation. This contextual typing does not relabel an expression: comparing a
|
|
|
89
89
|
`SqlUuid` expression with a `SqlText` expression is still rejected. Cast when
|
|
90
90
|
the database operation intentionally changes domains:
|
|
91
91
|
|
|
92
|
+
Scalar text functions bind primitive operands automatically, and `coalesce()`
|
|
93
|
+
uses its first expression to type primitive fallbacks:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
upper("Ada") // UPPER(?)
|
|
97
|
+
coalesce(metrics.label, "Anonymous") // COALESCE("metrics"."label", ?)
|
|
98
|
+
```
|
|
99
|
+
|
|
92
100
|
```ts
|
|
93
101
|
import { cast, like, text } from "qubu"
|
|
94
102
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qubu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/aleclarson/qubu"
|
|
@@ -32,6 +32,18 @@
|
|
|
32
32
|
"types": "./dist/introspection.d.mts",
|
|
33
33
|
"import": "./dist/introspection.mjs"
|
|
34
34
|
},
|
|
35
|
+
"./introspection/mysql": {
|
|
36
|
+
"types": "./dist/introspection/mysql.d.mts",
|
|
37
|
+
"import": "./dist/introspection/mysql.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./introspection/postgres": {
|
|
40
|
+
"types": "./dist/introspection/postgres.d.mts",
|
|
41
|
+
"import": "./dist/introspection/postgres.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./introspection/sqlite": {
|
|
44
|
+
"types": "./dist/introspection/sqlite.d.mts",
|
|
45
|
+
"import": "./dist/introspection/sqlite.mjs"
|
|
46
|
+
},
|
|
35
47
|
"./mysql": {
|
|
36
48
|
"types": "./dist/mysql.d.mts",
|
|
37
49
|
"import": "./dist/mysql.mjs"
|
|
@@ -48,6 +60,18 @@
|
|
|
48
60
|
"types": "./dist/snapshot.d.mts",
|
|
49
61
|
"import": "./dist/snapshot.mjs"
|
|
50
62
|
},
|
|
63
|
+
"./snapshot/mysql": {
|
|
64
|
+
"types": "./dist/snapshot/mysql.d.mts",
|
|
65
|
+
"import": "./dist/snapshot/mysql.mjs"
|
|
66
|
+
},
|
|
67
|
+
"./snapshot/postgres": {
|
|
68
|
+
"types": "./dist/snapshot/postgres.d.mts",
|
|
69
|
+
"import": "./dist/snapshot/postgres.mjs"
|
|
70
|
+
},
|
|
71
|
+
"./snapshot/sqlite": {
|
|
72
|
+
"types": "./dist/snapshot/sqlite.d.mts",
|
|
73
|
+
"import": "./dist/snapshot/sqlite.mjs"
|
|
74
|
+
},
|
|
51
75
|
"./sqlite": {
|
|
52
76
|
"types": "./dist/sqlite.d.mts",
|
|
53
77
|
"import": "./dist/sqlite.mjs"
|