Changelog - 2026-11-08
The migration ledger takes a schema and a table
Enhancement Breaking ChangeIn one line. RelationalMigrationRunner places its ledger with ledger: { schema?, table? }, and the old ledgerTable option is gone.
What changed
ledgerreplacesledgerTable. Both fields are optional. The defaults are the tableignis_migrationsin the engine's default schema, so a runner built without options writes the same SQL as before.- Both names are checked and quoted. The same character check that guards a migration name runs on
schemaandtable, and the SQL is written"schema"."table". - Postgres creates the schema when it is missing. When
schemais set, the runner looks it up first and runsCREATE SCHEMAonly if it is absent, in the same transaction as the ledger table. The first boot does not fail on a missing schema, and a role without theCREATEprivilege on the database works with a schema that already exists. - SQLite accepts only
main. Any otherschemathrows at construction, naming the problem, and is never ignored. - A driver says which engine it speaks.
IRelationalDriverhas an optionaldialect('postgres'or'sqlite'). The four built-in drivers declare it. A hand-made driver that does not can still settable, but aschemais refused because the runner cannot tell whether the engine has schemas. - The ledger table is created in its own transaction. Before,
CREATE TABLE IF NOT EXISTSran outside any transaction. A migration and its ledger row still commit together.
Who is affected
- Code that passes
ledgerTable. The runner throws at construction and points toledger. Rename the option. - Code that builds a runner with no options. No action needed: same table, same schema.
- Authors of a custom
IRelationalDriver. No action needed. Adddialectonly if you want to setledger.schema.
Breaking changes
WARNING
ledgerTable is removed, with no alias. A runner that still passes it throws when it is constructed.
Before:
typescript
const runner = new RelationalMigrationRunner({
driver,
ledgerTable: 'ignis_browser_migrations',
});
await runner.run({ migrations: MIGRATIONS });After:
typescript
const runner = new RelationalMigrationRunner({
driver,
ledger: { schema: 'public', table: 'ignis_browser_migrations' },
});
await runner.run({ migrations: MIGRATIONS });Details
- The ledger stays a one-column table keyed on the migration name, with no content hash.
- On a first boot the runner opens one small transaction for the schema and the table, then one transaction per migration with its ledger row.
- The lookup exists because
CREATE SCHEMA IF NOT EXISTSchecks theCREATEprivilege on the database before it checks for the schema, so it fails for a restricted role even onpublic. A restricted role still needs the privilege, or an existing schema, when the schema is really missing.
| File | Package |
|---|---|
src/relational/core/migrations/runner.ts | connectors |
src/relational/core/drivers/driver.ts | connectors |
src/relational/postgres/drivers/*.ts | connectors |
src/relational/sqlite/drivers/libsql.ts | connectors |