Reylo v0.9.0 types queries on ClickHouse, in preview, generates one TypeScript module from a project's queries, and deploys a long migration history several times faster.
Four changes can surface in an existing project, listed in Upgrading from v0.8.3.
ClickHouse, in preview
Reylo now types queries on ClickHouse 25.11 and later, in preview: its types and parameter syntax may still change (#344).
SELECT id, name, email
FROM users
WHERE id = {id:UInt64}
LIMIT 1The query runs on the official client:
import { createClient } from "@clickhouse/client";
import getUser from "./get_user.sql";
const db = createClient({ url: process.env.CLICKHOUSE_URL });
const user = await getUser.run(db, { id: 1 });
// { id: bigint; name: string; email: string | null } | nullWhat it covers:
- Connection: a
clickhouse+http://orclickhouse+https://URL to the server's HTTP interface, and no client for the type check - Types: every column from ClickHouse's own
DESCRIBEof the query, arrays, tuples and maps included, and nullable only where its type isNullable - Parameters: written as ClickHouse writes them,
{id:UInt64}, or as:id::UInt64 - Cardinality: from the server's query tree, so a
LIMIT 1returns at most one row and an aggregate with noGROUP BYreturns one - Clients:
@clickhouse/clientand@clickhouse/client-web - Writes:
INSERT,UPDATE,DELETEandALTER TABLE … UPDATEorDELETE, each checked without being run, and refused where it writes a value its column can't hold (#447) - Not yet: Reylo Migrate, which has no migrations for ClickHouse
TypeScript codegen
The reylo generate typescript command writes every query into one TypeScript module (#437).
reylo generate typescript 'src/queries/**/*.sql' --out src/queries.tsEach file becomes an export named after it:
import { getUser } from "./queries.ts";
const user: getUser.Row | null = await getUser.run(db, { id: 1 });What it covers:
- Setup: no content mapper, bundler plugin or preload, on TypeScript 5.9 and 7.1, and under Node's type stripping
- Types:
Params,RowandQueryErroron a namespace of each export's name - Errors: any error the type check would report fails the run, and nothing is written
Reylo Migrate
A deploy now reads the database's schema once, after its last migration, where it read it after every migration (#436). From an empty Postgres 18 database:
| Case | Before | After | Speedup |
|---|---|---|---|
| 150 one-table migrations | 8.1 s | 1.0 s | 8.1× |
| 140 migrations of a production app | 11.3 s | 1.0 s | 11.3× |
| 150 one-table migrations, 10 ms round trip | 115.7 s | 16.1 s | 7.2× |
What else changed:
- Builds before a deploy:
reylo migrate deploy --dry-run -- next buildruns the build against a shadow of the schema the deploy leaves, for a host that builds before it migrates (#480) - Dry runs:
reylo migrate deploy --dry-runsays what each pending migration drops and which of the target's rows break the constraints it adds, with a query that lists them (#479) - Supabase: a project started with
reylo migrate initon Supabase deploys to a new Supabase database, a branch or one aftersupabase db reset, wheredeployrefused it as changed outside its migrations (#478) - Existing databases:
reylo migrate initandreylo db introspectwrite a Postgres database's default privileges and grants on schemas, whereinit.sqlheld only their revokes, andinitnames the roles it needs (#431) - Moving from another tool: the history tables of Prisma Migrate, Drizzle Kit, Knex, Flyway and other migration tools are left out of the schema, where
initwrote them intoschema.sql(#434) - Short stamps: a migration whose name starts with a shorter stamp, as Prisma accepts, is told to pad it in place, where it was told to take today's time (#433)
- Changed indexes: a changed Postgres index or key is built concurrently and then takes the old one's place, where the old one was dropped a migration before the new one was built (#439)
- Renames: a rename's refusals settle in one run, a suggested command carries
--blockingwhere its migration rewrites a table, and a renamed Postgres column keeps the keys, indexes and partition key over it, where they were dropped and made again (#430, #451, #481) - Rows a deploy stops on: a deploy that fails on rows already in a table names the constraint, what of the change is in place and a query that lists the rows, where it said to fix the file (#432)
- MySQL changes: a migration's
alter tableruns in strict mode, so a change that can't hold a row's value fails on it, where a server that isn't strict rewrote the value (#438) - Identity starts: a changed
start withmoves a Postgres sequence on to the new start, where a migrated database kept counting from where it was (#440) - Partitioning a table: making a Postgres table partitioned, or plain again, prints the statements that keep its rows, where it was refused as a drop (#440)
- Skipped migrations:
reylo migrate history pushrecords a database that skipped one migration and moves that migration last in the lock, where it refused (#441)
Upgrading from v0.8.3
Each change below can surface in a project that upgrades from v0.8.3.
Every dialect
- Each enum value in a type descriptor is an object,
{ "value": "active" }, where it was the string"active". Read.valuewhere code reads whatreylo analyzeoranalyze()prints; the types.sqlmodules get are unchanged (#420). - A migration that grants or revokes a role is refused by
reylo migrate deploy, which ran it. Run it with the server's setup, outside the migrations, as the refusal says (#435).
Postgres
- A Supabase project begun with v0.8 or earlier is refused on a database that has
supabase_realtime, since itsinit.sqlcreates that publication. Start the project again with the commands the refusal gives, which also say where its old migrations' rows go (#478).
MySQL
- A migration's
alter tablefails on a value its new type can't hold, where a server that isn't strict changed the value. Fix those rows before the deploy (#438).
What's Changed
- fix(cli): say that migrate dev rewinds as needed by @colinhacks in #428
- fix(cli): put the data-loss warning on the migrate dev rewind by @colinhacks in #429
- fix(engine): pad a migration's shorter stamp where its name sorts by @colinhacks in #433
- fix(engine): write default privileges and schema grants in init.sql by @colinhacks in #431
- fix(engine): leave other migration tools' history tables out by @colinhacks in #434
- feat(cli): generate typescript, and rust-sqlx into one flat file by @colinhacks in #437
- fix(cli): say how to keep a role in a migration, and refuse it at deploy by @colinhacks in #435
- fix(engine): settle migrate's rename refusals in one run by @colinhacks in #430
- perf(engine): read the migrated schema's fingerprint once per run by @colinhacks in #436
- feat(clickhouse): add ClickHouse support by @colinhacks in #344
- fix(engine): stop the type check waiting forever on a table lock by @colinhacks in #443
- fix(migrate): name the rows and changes a deploy stops on by @colinhacks in #432
- fix(migrate): make mysql enum, partition and trigger changes safe by @colinhacks in #438
- fix(cli): move a skipped migration last, keep the history table private by @colinhacks in #441
- perf(postgres): read pg_attribute by its index in the unique-key query by @colinhacks in #446
- fix(migrate): rebuild external-content full-text indexes on sqlite by @colinhacks in #442
- fix(clickhouse): accept arithmetic on parameters a column keeps by @colinhacks in #447
- fix(migrate): compare postgres expressions as the server reads them back by @colinhacks in #450
- fix(migrate): lock init.sql as the checks read it back by @colinhacks in #454
- fix(migrate): keep postgres keys over a renamed column in place by @colinhacks in #451
- test(migrate): lock an init.sql with a carriage return in a string by @colinhacks in #458
- fix(engine): note on the hover when a statement nests past the bound by @colinhacks in #459
- test(migrate): offer no rename onto another table's renamed column by @colinhacks in #461
- fix(migrate): settle a changed identity start and partitioning a table by @colinhacks in #440
- docs: improve readability, structure and agent friendliness by @colinhacks in #455
- fix(migrate): remake a foreign key whose columns change collation by @colinhacks in #474
- fix(cli): refuse db introspect on a shadow_url that makes no shadow by @colinhacks in #482
- feat(spec)!: write enum values as objects by @colinhacks in #420
- fix(engine): lift mysql and sqlite parse bounds set for webassembly by @colinhacks in #486
- fix(migrate): leave temporary tables' objects out of the schema by @colinhacks in #490
- test(migrate): round-trip every diff case with its rows by @colinhacks in #485
- test(clickhouse): write enum values as objects in the type test by @colinhacks in #492
- fix: refuse an effect sql client in .run() by @colinhacks in #494
- feat(engine): check pending migrations' drops and rows in dry runs by @colinhacks in #479
- ci: run only the jobs a pull request's change reaches by @colinhacks in #493
- docs(site): add host pages for running reylo migrate deploy by @colinhacks in #477
- fix(migrate): refuse a role in schema.sql before any shadow by @colinhacks in #487
- fix(site): load the docs' fonts on reylo play's page by @colinhacks in #498
- feat(migrate): run a build on the dry run's shadow database by @colinhacks in #480
- fix(migrate): rename a partition key's column in place by @colinhacks in #481
- fix(engine): name what a renamed table keeps as Postgres would by @colinhacks in #460
- fix(migrate): plan six schema changes the fuzzer found by @colinhacks in #491
- feat(cli): tighten refusals, one command for lossy columns by @colinhacks in #484
- fix(migrate): rename a sqlite column its table names qualified by @colinhacks in #499
- fix(migrate): build a changed postgres index before dropping the old one by @colinhacks in #439
- fix(migrate): remake row holders around rewrites of their relation by @colinhacks in #500
- fix(mysql): call every bit inside json a string in the output schema by @smorimoto in #503
- fix(postgres): stop each cast in a chain doubling the analysis time by @smorimoto in #504
- fix: name null once in the json schema of an always-null value by @smorimoto in #506
- fix(postgres): trim a bun.sql time's fraction as postgres writes it by @smorimoto in #501
- chore(release): 0.9.0 by @colinhacks in #444
- fix(migrate): deploy onto a fresh supabase database by @colinhacks in #478
New Contributors
- @smorimoto made their first contribution in #503
Full Changelog: v0.8.3...v0.9.0