Reference
MySQL snapshot support
Check which MySQL schema features the Snapshot v1 adapter can save.
Import the adapter from the MySQL snapshot subpath:
import { createSchemaSnapshot, tryCreateSchemaSnapshot } from "qubu/snapshot/mysql"
const snapshot = createSchemaSnapshot(appSchema)
const result = tryCreateSchemaSnapshot(appSchema)
The snapshot dialect is named mysql, the same name used by Qubu's query
renderer. A dialect-tagged unsafeSchemaSql('mysql', sql) expression belongs
to this adapter.
Support matrix
| Schema fact | MySQL v1 behavior |
|---|---|
| Portable storage | Uses the mappings below. |
| Native storage | Preserves a non-empty declaration tagged mysql exactly. Native declarations owned by another dialect fail. |
| Literals | Encodes NULL, finite numbers, strings, booleans, and bigint without query parameters. Strings use SQL quote doubling. |
| Defaults | Canonical literals, branded deterministic expressions, and explicit external behavior are retained. Default expressions cannot reference columns or parameters. |
ON UPDATE |
A branded, parameter-free column expression is retained as onUpdate. PostgreSQL and SQLite adapters diagnose this MySQL-only fact. |
| AUTO_INCREMENT | identityColumn(..., { dialect: { dialect: 'mysql', autoIncrement: true } }) is retained as a column-level identity extension. The column must be non-nullable, integer-family storage, and the first term of a key. |
| Generated columns | Both stored and virtual modes are retained. Generated columns cannot also use ON UPDATE or AUTO_INCREMENT. |
| Keys and checks | Primary keys, strict unique keys, ordinary unique constraints, foreign keys, and checks retain logical and physical names, actions, and typed MySQL extension data. |
| Foreign keys | MATCH SIMPLE and standard actions except SET DEFAULT are supported. MATCH FULL, MATCH PARTIAL, deferrability, and SET DEFAULT are diagnosed. |
| Nullable uniqueness | nulls: 'distinct' is supported. nulls: 'not-distinct' is diagnosed because ordinary MySQL UNIQUE constraints allow multiple NULL values. |
| Indexes | Ordered terms, expressions, uniqueness, and candidate-key evidence are retained. Partial predicates, included columns, and NULLS FIRST/LAST are diagnosed. Algorithm, locking, access method, parser, and key-block options live under dialect. |
| Names | Table, column, constraint, and index names are checked against MySQL's 64-character identifier limit. Table names are database-scoped; index names are table-scoped. |
Portable storage types
| Qubu storage | Database declaration |
|---|---|
integer |
INT |
numeric |
DECIMAL |
text |
TEXT |
boolean |
BOOLEAN |
date |
DATE |
timestamp |
DATETIME |
uuid |
CHAR(36) |
json |
JSON |
bigint |
BIGINT |
binary |
VARBINARY |
Diagnostics
Capability checks run before common traversal. Use the non-throwing form when a schema may include a MySQL engine or version-specific feature:
const result = tryCreateSchemaSnapshot(appSchema)
if (!result.ok) {
for (const issue of result.diagnostics) {
console.error(issue.path.join("."), issue.code, issue.message)
}
}
The adapter does not connect to MySQL, inspect information_schema, or emit
DDL. It produces deterministic data for the strict qubu/snapshot decoder.
The package-wide ownership map
shows the separate schema and application boundaries.