Repository navigation
Releases
0.29.9
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
Kysely's migrator no longer records timestamps that go backwards when the wall clock jumps back during a migration run (WSL2/VM time sync, an NTP step, an unsmeared leap second). Such timestamps made every later migrateToLatest() fail with "corrupted migrations", even though the migrations ran in the correct order. The migrator now reads the latest recorded timestamp while holding the migration lock, and records each new migration at max(now, latest + 1ms), so the order holds across runs and hosts. Executed migrations with an invalid timestamp now fail with "corrupted migrations" instead of being sorted arbitrarily.
Migration tables that already have out-of-order timestamps need a one-time repair. Run the query for your dialect below. It goes through executed migrations in name order, which is the order the migrator runs them in by default, and moves every timestamp that isn't later than the previous one to 1 millisecond after it. Running it again changes nothing.
Replace kysely_migration with your migration table's name, prefixed with the schema if you set migrationTableSchema. Run it while no migrations are running. Skip this if you use allowUnorderedMigrations: true. Name order isn't the execution order in that mode, and out-of-order timestamps don't block migrations there.
PostgreSQL and PGlite:
with ordered as (
select
name,
(extract(epoch from "timestamp"::timestamptz) * 1000)::bigint as executed_at,
row_number() over (order by name collate "C") as position
from kysely_migration
),
repaired as (
select
name,
executed_at,
position + max(executed_at - position) over (order by position) as repaired_executed_at
from ordered
)
update kysely_migration
set "timestamp" = to_char(
(timestamptz 'epoch' + repaired_executed_at * interval '1 millisecond') at time zone 'UTC',
'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'
)
from repaired
where kysely_migration.name = repaired.name
and repaired.repaired_executed_at <> repaired.executed_at;MySQL 8.0+:
update kysely_migration
join (
select
name,
executed_at,
position + max(executed_at - position) over (order by position) as repaired_executed_at
from (
select
name,
timestampdiff(
microsecond,
'1970-01-01',
str_to_date(`timestamp`, '%Y-%m-%dT%H:%i:%s.%fZ')
) div 1000 as executed_at,
row_number() over (order by cast(name as binary)) as position
from kysely_migration
) as ordered
) as repaired using (name)
set kysely_migration.`timestamp` = concat(
date_format(
timestamp '1970-01-01 00:00:00' + interval repaired.repaired_executed_at * 1000 microsecond,
'%Y-%m-%dT%H:%i:%s.'
),
lpad(repaired.repaired_executed_at mod 1000, 3, '0'),
'Z'
)
where repaired.repaired_executed_at <> repaired.executed_at;MS SQL Server 2016+:
with ordered as (
select
name,
datediff_big(millisecond, '1970-01-01', convert(datetime2(3), [timestamp], 127)) as executed_at,
row_number() over (order by name collate Latin1_General_BIN2) as position
from kysely_migration
),
repaired as (
select
name,
executed_at,
position + max(executed_at - position) over (order by position rows unbounded preceding) as repaired_executed_at
from ordered
)
update kysely_migration
set [timestamp] = convert(
varchar(19),
dateadd(
millisecond,
repaired.repaired_executed_at % 86400000,
dateadd(day, repaired.repaired_executed_at / 86400000, cast('1970-01-01' as datetime2(3)))
),
126
) + '.' + right('00' + cast(repaired.repaired_executed_at % 1000 as varchar(3)), 3) + 'Z'
from kysely_migration
join repaired on repaired.name = kysely_migration.name
where repaired.repaired_executed_at <> repaired.executed_at;SQLite 3.33+:
with ordered as (
select
name,
cast(round((julianday("timestamp") - 2440587.5) * 86400000) as integer) as executed_at,
row_number() over (order by name collate binary) as position
from kysely_migration
),
repaired as (
select
name,
executed_at,
position + max(executed_at - position) over (order by position) as repaired_executed_at
from ordered
)
update kysely_migration
set "timestamp" = strftime('%Y-%m-%dT%H:%M:%S', repaired_executed_at / 1000, 'unixepoch')
|| printf('.%03dZ', repaired_executed_at % 1000)
from repaired
where kysely_migration.name = repaired.name
and repaired.repaired_executed_at <> repaired.executed_at;The binary collations (collate "C", cast(name as binary), etc.) make the database sort names the same way the migrator does in JavaScript.
Also, PGlite 0.5.15+ commits that roll back aborted transactions now throw AbortedTransactionError, same as PostgreSQL since 0.29.8.
🚀 Features
🐞 Bugfixes
- fix: inline
key()/at()JSON path references inferunknowninjsonBuildObject. by @igalklebanov in #2228 - fix: migration timestamps go backwards when the clock jumps back. by @igalklebanov in #2248
PostgreSQL 🐘 / PGlite 🟨
- fix:
withSchemacrashes onfor ... ofandjson_agg/to_jsontables in subqueries. by @igalklebanov in #2227
PGlite 🟨
- fix(pglite): reject commits that roll back aborted transactions by @igalklebanov in #2217
📖 Documentation
- docs(site): add Omnea to proof wall by @igalklebanov in #2220
- docs(site): add ZenStack creator's quote by @igalklebanov in #2230
- docs(site): add Capacities, Disney, Talentir, and Teamspective to proof wall by @igalklebanov in #2229
- docs(site): refresh proof wall permalinks by @igalklebanov in #2231
- docs(site): explain installed-version API guidance for agents by @igalklebanov in #2190
- docs(site): expand raw SQL recipe by @igalklebanov in #2191
- docs(site): compare Kysely and Knex by @igalklebanov in #2184
- docs: document compiled queries and raw execution by @igalklebanov in #2177
- docs: document file migration provider customization by @igalklebanov in #2179
- docs(site): add OpenWork to proof wall by @igalklebanov in #2232
- feat(site): adopt Pagefind 1.6 search options. by @igalklebanov in #2233
- docs(site): raise the weekly downloads fallback to 20M+ by @igalklebanov in #2240
- docs(site): compare Kysely and Drizzle by @igalklebanov in #2186
- docs(site): add OpenPencil to proof wall by @igalklebanov in #2243
- docs(site): compare Kysely and TypeORM by @igalklebanov in #2187
📦 CICD & Tooling
- chore: remove example project. by @igalklebanov in #2241
- chore: bump dependencies. by @igalklebanov in #2250
⚠️ Breaking Changes
key()andat()no longer accept a 2nd type argument for the output type (e.g..key<'url', number>('url')). It was never documented. Use$castTo<T>()to override the output type. (#2228)
🐤 New Contributors
What's Changed
Full Changelog: v0.29.8...v0.29.9
0.28.20
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
This maintenance release backports the fixes from 0.29.9.
Kysely's migrator no longer records timestamps that go backwards when the wall clock jumps back during a migration run (WSL2/VM time sync, an NTP step, an unsmeared leap second). Such timestamps made every later migrateToLatest() fail with "corrupted migrations", even though the migrations ran in the correct order. The migrator now reads the latest recorded timestamp while holding the migration lock, and records each new migration at max(now, latest + 1ms), so the order holds across runs and hosts. Executed migrations with an invalid timestamp now fail with "corrupted migrations" instead of being sorted arbitrarily.
Migration tables that already have out-of-order timestamps need a one-time repair. Run the query for your dialect below. It goes through executed migrations in name order, which is the order the migrator runs them in by default, and moves every timestamp that isn't later than the previous one to 1 millisecond after it. Running it again changes nothing.
Replace kysely_migration with your migration table's name, prefixed with the schema if you set migrationTableSchema. Run it while no migrations are running. Skip this if you use allowUnorderedMigrations: true. Name order isn't the execution order in that mode, and out-of-order timestamps don't block migrations there.
PostgreSQL:
with ordered as (
select
name,
(extract(epoch from "timestamp"::timestamptz) * 1000)::bigint as executed_at,
row_number() over (order by name collate "C") as position
from kysely_migration
),
repaired as (
select
name,
executed_at,
position + max(executed_at - position) over (order by position) as repaired_executed_at
from ordered
)
update kysely_migration
set "timestamp" = to_char(
(timestamptz 'epoch' + repaired_executed_at * interval '1 millisecond') at time zone 'UTC',
'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'
)
from repaired
where kysely_migration.name = repaired.name
and repaired.repaired_executed_at <> repaired.executed_at;MySQL 8.0+:
update kysely_migration
join (
select
name,
executed_at,
position + max(executed_at - position) over (order by position) as repaired_executed_at
from (
select
name,
timestampdiff(
microsecond,
'1970-01-01',
str_to_date(`timestamp`, '%Y-%m-%dT%H:%i:%s.%fZ')
) div 1000 as executed_at,
row_number() over (order by cast(name as binary)) as position
from kysely_migration
) as ordered
) as repaired using (name)
set kysely_migration.`timestamp` = concat(
date_format(
timestamp '1970-01-01 00:00:00' + interval repaired.repaired_executed_at * 1000 microsecond,
'%Y-%m-%dT%H:%i:%s.'
),
lpad(repaired.repaired_executed_at mod 1000, 3, '0'),
'Z'
)
where repaired.repaired_executed_at <> repaired.executed_at;MS SQL Server 2016+:
with ordered as (
select
name,
datediff_big(millisecond, '1970-01-01', convert(datetime2(3), [timestamp], 127)) as executed_at,
row_number() over (order by name collate Latin1_General_BIN2) as position
from kysely_migration
),
repaired as (
select
name,
executed_at,
position + max(executed_at - position) over (order by position rows unbounded preceding) as repaired_executed_at
from ordered
)
update kysely_migration
set [timestamp] = convert(
varchar(19),
dateadd(
millisecond,
repaired.repaired_executed_at % 86400000,
dateadd(day, repaired.repaired_executed_at / 86400000, cast('1970-01-01' as datetime2(3)))
),
126
) + '.' + right('00' + cast(repaired.repaired_executed_at % 1000 as varchar(3)), 3) + 'Z'
from kysely_migration
join repaired on repaired.name = kysely_migration.name
where repaired.repaired_executed_at <> repaired.executed_at;SQLite 3.33+:
with ordered as (
select
name,
cast(round((julianday("timestamp") - 2440587.5) * 86400000) as integer) as executed_at,
row_number() over (order by name collate binary) as position
from kysely_migration
),
repaired as (
select
name,
executed_at,
position + max(executed_at - position) over (order by position) as repaired_executed_at
from ordered
)
update kysely_migration
set "timestamp" = strftime('%Y-%m-%dT%H:%M:%S', repaired_executed_at / 1000, 'unixepoch')
|| printf('.%03dZ', repaired_executed_at % 1000)
from repaired
where kysely_migration.name = repaired.name
and repaired.repaired_executed_at <> repaired.executed_at;The binary collations (collate "C", cast(name as binary), etc.) make the database sort names the same way the migrator does in JavaScript.
🚀 Features
🐞 Bugfixes
- fix: inline
key()/at()JSON path references inferunknowninjsonBuildObject. by @igalklebanov in #2228 - fix: migration timestamps go backwards when the clock jumps back. by @igalklebanov in #2248
PostgreSQL 🐘
- fix:
withSchemacrashes onfor ... ofandjson_agg/to_jsontables in subqueries. by @igalklebanov in #2227
📖 Documentation
📦 CICD & Tooling
⚠️ Breaking Changes
key()andat()no longer accept a 2nd type argument for the output type (e.g..key<'url', number>('url')). It was never documented. Use$castTo<T>()to override the output type. (#2228)
🐤 New Contributors
What's Changed
Full Changelog: v0.28.19...v0.28.20
0.29.8
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
PostgreSQL transactions get two fixes:
- Clients whose rollback fails are discarded instead of returned to the pool for reuse.
- Commits that PostgreSQL turns into rollbacks now throw
AbortedTransactionErrorinstead of reporting success. Controlled transactions are marked as rolled back and release their connection; a subsequentrollback().execute()safely succeeds without sending another rollback.
🚀 Features
🐞 Bugfixes
PostgreSQL 🐘
- fix(postgres): discard clients after failed rollbacks by @igalklebanov in #2155
- fix(postgres): reject commits that roll back aborted transactions by @igalklebanov in #2161
📖 Documentation
- fix(site): prevent quote grid resize loops by @igalklebanov in #2158
- docs(site): compare SQL query builders and ORMs by @igalklebanov in #2181
- docs(site): add TREK to proof wall by @igalklebanov in #2196
- docs(site): add Craig to proof wall by @igalklebanov in #2197
- docs(site): compare SQL query builders and raw SQL in TypeScript by @igalklebanov in #2182
📦 CICD & Tooling
⚠️ Breaking Changes
🐤 New Contributors
What's Changed
Full Changelog: v0.29.7...v0.29.8
0.28.19
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
This maintenance release backports the PostgreSQL transaction fixes from 0.29.8.
PostgreSQL transactions get two fixes:
- Clients whose rollback fails are discarded instead of returned to the pool for reuse.
- Commits that PostgreSQL turns into rollbacks now throw
AbortedTransactionErrorinstead of reporting success. Controlled transactions are marked as rolled back and release their connection; a subsequentrollback().execute()safely succeeds without sending another rollback.
🚀 Features
🐞 Bugfixes
PostgreSQL 🐘
- fix(postgres): discard clients after failed rollbacks by @igalklebanov in #2155
- fix(postgres): reject commits that roll back aborted transactions by @igalklebanov in #2161
📖 Documentation
📦 CICD & Tooling
⚠️ Breaking Changes
🐤 New Contributors
What's Changed
Full Changelog: v0.28.18...v0.28.19
0.29.7
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
Controlled transactions get fixes for connection leaks, shared completion state, and commands racing with ongoing queries:
- Commit, rollback, and savepoint commands now wait for ongoing queries and streams to finish.
- Close or exhaust active streams before awaiting these commands.
- A failed rollback now releases the connection and marks the transaction as rolled back.
🚀 Features
🐞 Bugfixes
- fix: release controlled transaction connection when begin fails by @igalklebanov in #2080
- fix: share completion state between controlled transaction handles by @igalklebanov in #2090
- fix: release controlled transaction connection when rollback fails by @B4nan in #2136
- fix: serialize controlled transaction commands with queries by @igalklebanov in #2081
PostgreSQL 🐘
- fix(postgres): release the client when destroyed while acquiring a connection by @abebelagua & @igalklebanov in #2088
MSSQL 🥅
- fix(mssql): escape
jsonBuildObjectkeys. by @igalklebanov in #2078 - fix(mssql): escape JSON in
jsonBuildObjectby @igalklebanov in #2079
📖 Documentation
- docs: add Langfuse to the built-into proof wall by @igalklebanov in #2054
- docs: add TrueForge to the built-into proof wall by @igalklebanov in #2055
- docs: add Open Mercato to the built-into proof wall by @igalklebanov in #2056
- docs: make homepage title descriptive by @igalklebanov in #2058
- fix(site): preload the homepage video poster with high priority by @igalklebanov in #2059
- fix(site): stabilize demo video dimensions by @igalklebanov in #2060
- docs: add a default social preview card by @igalklebanov in #2061
- docs: share the homepage description and refresh production examples by @igalklebanov in #2062
- docs: add descriptions to non-example pages by @igalklebanov in #2063
- fix(site): stabilize search label and center shortcut keys by @igalklebanov in #2064
- fix(site): serve Markdown for explicit Accept requests by @igalklebanov in #2066
- fix(site): expose agent documentation discovery hint by @igalklebanov in #2065
- fix(site): add agent discovery hints to Markdown pages by @igalklebanov in #2067
- fix(site): remove HTML comments from generated Markdown by @igalklebanov in #2068
- fix(site): include category pages in agent documentation by @igalklebanov in #2069
- fix(site): reduce homepage Markdown size by @igalklebanov in #2071
- docs(site): improve API reference discovery by @igalklebanov in #2072
- docs(site): publish robots.txt with sitemap by @igalklebanov in #2074
- docs(site): advertise agent index in homepage Link header by @igalklebanov in #2075
- docs(site): declare content usage preferences by @igalklebanov in #2076
- docs: audit the proof wall and refresh usage evidence by @igalklebanov in #2085
- fix(site): serve Markdown 404 responses to agents by @igalklebanov in #2089
- docs: add software identity and maintainer contact structured data by @igalklebanov in #2091
- docs: declare Open Graph website type by @igalklebanov in #2092
- docs: link organization identity profiles in JSON-LD by @igalklebanov in #2093
- docs: add LinkedIn to organization structured data by @igalklebanov in #2095
- docs: generate agent discovery catalogs by @igalklebanov in #2094
- docs: compress testimonial avatars by @igalklebanov in #2098
- docs: render each testimonial once by @igalklebanov in #2099
- perf(site): defer Prism until documentation is loaded by @igalklebanov in #2100
- perf(site): preload search when the browser is idle by @igalklebanov in #2101
- fix(site): improve hero audit text contrast by @igalklebanov in #2102
- docs(site): add A2A JavaScript SDK to proof wall by @igalklebanov in #2103
- fix(site): preserve testimonial avatar aspect ratios by @igalklebanov in #2106
- fix(site): enlarge theme toggle touch targets by @igalklebanov in #2105
- fix(site): show the demo poster before hydration by @igalklebanov in #2107
- fix(site): improve light-mode accent contrast by @igalklebanov in #2108
- perf(site): preload the demo poster before stylesheets by @igalklebanov in #2112
- perf(site): externalize proof-wall logo artwork by @igalklebanov in #2114
- fix(site): show brand names while the logo sprite loads by @igalklebanov in #2116
- docs: fix PostgreSQL pool in plugin example by @igalklebanov in #2117
- docs: consolidate Deno guidance in getting started by @igalklebanov in #2118
- docs: enable Bun SQLite with better-sqlite3 by @igalklebanov in #2124
- docs: describe the
LogEventunion by @igalklebanov in #2121 - docs: qualify PGlite type generation support by @igalklebanov in #2120
- docs: add kysely-typegen to type generators by @theoludwig & @igalklebanov in #2126
- docs(site): remove duplicate intro help paragraph by @igalklebanov in #2133
- fix(site): respect reduced motion and add demo playback control by @igalklebanov in #2130
- docs: clarify shared pool and database instance lifecycles by @igalklebanov in #2143
📦 CICD & Tooling
- ci: replace llms text comparison with local afdocs checks by @igalklebanov in #2070
- chore(deps): bump afdocs to 0.22.2 by @igalklebanov in #2087
- ci: use non-Docker Hub images for PostgreSQL and MySQL. by @igalklebanov in #2127
- ci: add registry fallbacks and reuse the SQL Server image by @igalklebanov in #2140
- chore: bump deps. by @igalklebanov in #2142
⚠️ Breaking Changes
🐤 New Contributors
- @theoludwig made their first contribution in #2126
- @abebelagua made their first contribution in #2088
What's Changed
Full Changelog: v0.29.6...v0.29.7
0.28.18
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
This maintenance release backports bug fixes and documentation improvements from the 0.29 line.
Controlled transactions get fixes for connection leaks, shared completion state, and commands racing with ongoing queries:
- Commit, rollback, and savepoint commands now wait for ongoing queries and streams to finish.
- Close or exhaust active streams before awaiting these commands.
- A failed rollback now releases the connection and marks the transaction as rolled back.
PostgreSQL and MSSQL now use session-level migration locks, including with disableTransactions: true. PostgreSQL migrations through PgBouncer transaction pooling need a direct connection, session pooling, or custom migration locking.
🚀 Features
🐞 Bugfixes
- fix: allow explicit
undefinedinUpdateablewithexactOptionalPropertyTypes. by @y-hsgw in #1496 - fix infinite type check recursion by @koskimas in #1960
- fix: release controlled transaction connection when begin fails by @igalklebanov in #2080
- fix: share completion state between controlled transaction handles by @igalklebanov in #2090
- fix: release controlled transaction connection when rollback fails by @B4nan in #2136
- fix: serialize controlled transaction commands with queries by @igalklebanov in #2081
PostgreSQL 🐘 / MSSQL 🥅
- fix: PostgreSQL and MSSQL migrations are not running exclusively when
disableTransactions: true. by @morgan-coded & @igalklebanov in #1919
PostgreSQL 🐘 / SQLite 📘
- fix: allow immutable columns in
doUpdateSet'swhere. by @igalklebanov in #2043
On-conflict WHERE predicates now use column select types, including for columns that cannot be updated.
PostgreSQL 🐘
- refactor(postgres): optimize table metadata parsing in
PostgresIntrospectorby @igalklebanov & @rubenferreira97 in ba89cc3 - fix(postgres): release the client when destroyed while acquiring a connection by @abebelagua & @igalklebanov in #2088
SQLite 📘
- fix(sqlite): output
RETURNINGbeforeORDER BYandLIMITin delete queries. by @igalklebanov in #1946
MSSQL 🥅
- fix(mssql): escape
jsonBuildObjectkeys. by @igalklebanov in #2078 - fix(mssql): escape JSON in
jsonBuildObjectby @igalklebanov in #2079
📖 Documentation
- docs: fix PostgreSQL pool in plugin example by @igalklebanov in #2117
- docs: describe the
LogEventunion by @igalklebanov in #2121 - docs: clarify shared pool and database instance lifecycles by @igalklebanov in #2143
- Fix typo in
CreateTypeBuilder.asEnumdocstring by @anonpay-sh in ff15048
📦 CICD & Tooling
- ci: prepare
0.28.xmaintenance releases by @igalklebanov in 5e97e1d - ci: publish maintenance releases under the
release-0.28npm tag by @igalklebanov in 44e7c9a - test: adapt earlier
0.29regression tests to0.28APIs by @igalklebanov in 7d037af
⚠️ Breaking Changes
PostgreSQL 🐘
- PostgreSQL migrations now use session-level advisory locks, including when transactions are enabled. This is incompatible with PgBouncer transaction pooling and other transaction-mode connection poolers. Run migrations through a direct connection, session pooling, or custom migration locking. Otherwise, migration locks can remain held on pooled connections and block subsequent migration runs. See #1919 and #2200.
🐤 New Contributors
What's Changed
Full Changelog: v0.28.17...v0.28.18
0.29.6
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
🚀 Features
🐞 Bugfixes
PostgreSQL 🐘 / SQLite 📘
- fix: allow immutable columns in
doUpdateSet'swhere. by @igalklebanov in #2043
📖 Documentation
- feat(site): grow the proof wall from npm's dependents (Cypress, Canton, Tailor, Supabase Lite) + verify every pin by @igalklebanov in #1985
- Update link to Migrator API docs by @ardouglass in #1991
📦 CICD & Tooling
- chore: bumps dependencies. by @igalklebanov in #2045
⚠️ Breaking Changes
🐤 New Contributors
- @ardouglass made their first contribution in #1991
What's Changed
Full Changelog: v0.29.5...v0.29.6
0.30.0-beta.2
Hey 👋
0.30 season is upon us. pnpm i kysely@next and get a sneak peak into the future!
We've got a new transactionMode: 'per-run' | 'per-migration' | 'none' property you can pass to Migrator or it's methods.
'per-run'is the classic behavior you're used to wherekyselywrap the entire run in a transaction when your dialect supports transactional DDL.'per-migration'enables each migration to pick whether it runs in its own transaction or not. Just exposeconfig: { transaction: false }from the module, right next to theup/downfunctions.'none'means no transactions are used, which is similar to the now deprecateddisableTransactions: true.
import * as fs from 'node:fs/promises'
import * as path from 'node:path'
import { FileMigrationProvider, Migrator } from 'kysely/migration'
const migrator = new Migrator({
db,
provider: new FileMigrationProvider({
fs,
migrationFolder: path.join(import.meta.dirname, 'migrations'),
}),
transactionMode: 'per-migration', // <-------------------------------
})
await migrator.migrateToLatest()We've got a new defineMigration helper function that you can use to easily write your migrations and meet the contract requirements:
import { defineMigration } from 'kysely/migration'
export default defineMigration({
up: async (db) => {
// ...
},
config: { transaction: false }, // <--------------------
})You can now use mysql2/promise, where in the past it would hang forever since we only supported the callback style of mysql2 root import.
We're trying various type-level solutions that provide compilation performance and type-safety improvements of Kysely, Transaction, ControlledTransaction and their readonly variants. QueryCreator, FunctionModule, MergeQueryBuilder too.
We've got a new stream method on RawBuilder that allows you to:
import { sql } from 'kysely'
import { db } from 'path/to/db'
for await (const row of sql`select * from person`.stream(db)) {
// ...
}🚀 Features
- feat(migrator): add
migrateTo(name, { direction: 'Up' | 'Down' })to enforce direction. by @igalklebanov in #1957 - feat(introspector): add
whereoption for partial introspection. by @igalklebanov in #2005 - feat(introspector): add
whereoption ingetSchemas. by @igalklebanov in #2006 - feat(introspector): add
commentproperty in table metadata. by @igalklebanov in #2008 - feat: stream raw query results. by @igalklebanov in #2037
PostgreSQL 🐘 / MSSQL 🥅
- feat: Per-migration transaction configuration by @lourd & @igalklebanov in #1671
PostgreSQL 🐘
- feat(postgres): support introspecting materialized views. by @igalklebanov in #2010
MySQL 🐬
- feat(mysql): support both
mysql2andmysql2/promiseinMysqlDialect. by @igalklebanov in #1958 - feat(mysql): add
withNonDefaultDatabasesto support introspection of non-default databases. by @igalklebanov in #2007
SQLite 📘
- feat: deny passing BLOB-like columns to SQLite JSON helpers by @hwisu & @igalklebanov in #1698
- feat(sqlite): stream queries that return rows. by @igalklebanov in
#2036
🐞 Bugfixes
- fix: reject database assignments with missing tables. by @igalklebanov in #2015
- fix: allow transactions with extra tables to satisfy narrower schemas. by @igalklebanov in #2017
- fix: accept Kysely instances with extra tables on TypeScript 5. by @igalklebanov in #2018
- fix: preserve column read and write types in assignments. by @igalklebanov in #2019
- fix: preserve controlled transaction column write assignability. by @igalklebanov in #2022
- fix: preserve generic table extension assignability. by @igalklebanov in #2025
- fix: allow
ControlledTransaction<any>to satisfyTransaction<DB>. by @igalklebanov in #2027 - fix: preserve readonly schema guarantees during assignment. by @igalklebanov in #2029
- fix: allow compatible readonly transactions as database handles. by @igalklebanov in #2033
- fix: allow compatible readonly controlled transactions as parent handles. by @igalklebanov in #2034
📖 Documentation
- docs: correct
DummyDriverexecution JSDoc. by @igalklebanov in #2032
📦 CICD & Tooling
- test: add Vitest typechecking to TypeScript CI. by @igalklebanov in #2014
⚠️ Breaking Changes
disableTransactionsis deprecated. Use the newtransactionMode: 'none', ortransactionMode: 'per-migration'with combination ofconfig: { transaction: false }.- MySQL introspection now always excludes system databases -
mysql,information_schema,performance_schema,sysandnbinfotables will not be returned. - You might start seeing invocations of some your custom helpers failing compilation now that
Kysely,Transaction,ControlledTransactionand their readonly variants are compared more tightly.QueryCreator,FunctionModule,MergeQueryBuildertoo. Please report these cases.
SQLite 📘
- Trying to pass records with
BLOBcolumns in JSON helpers emits compile-time errors - e.g.KyselyTypeError<'SQLite does not support passing `BLOB` values to `json_object`. Cast to `TEXT`.'>
🐤 New Contributors
What's Changed
Full Changelog: v0.29.5...v0.30.0-beta.2
0.29.5
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
TypeScript 7 is allowing for deeper computations which now cause way more instantiations and wall clock times in various scenarios. We're diving deep into our types and finding optimizations. In this version @koskimas brought some nice wins for builder vs. builder assignability checks.
We're also revamping the docs site, working on style, message and usefulness. Swing by our Discord and share your opinions/ideas. We got docs->apidocs search now. The playground is back supporting short links and will allow saving short links very soon.
🚀 Features
🐞 Bugfixes
- fix infinite type check recursion by @koskimas in #1960
- Add missing beforeThrow calls in getInflightQueryAbortHandler by @lourd in #1971
📖 Documentation
- Fix typo in
CreateTypeBuilder.asEnumdocstring by @anonpay-sh in #1949 - chore: revamp docs hero page. by @igalklebanov in #1959
- fix(site): various issues with stats section. by @igalklebanov in #1966
- chore(site): replace most text proof with logos. by @igalklebanov in #1968
- feat(site): migrate to pagefind for cross-site search we own. by @igalklebanov in #1972
- chore(site): drop self-narrating captions, make proof arrows a standing cue by @igalklebanov in #1973
- feat(site): grow the proof wall (Replicas, EmbedPDF) + fix production hover by @igalklebanov in #1974
- feat(site): add AirTrail, bknd, Civitai, Corsair.dev, Hot Updater, Profilarr and Tunarr to the proof wall. by @igalklebanov in #1975
- feat(site): proof-strength gauges, query-module evidence, and new wall names by @igalklebanov in #1976
- feat(site): explain the proof gauge behind a (?) on the production wall by @igalklebanov in #1977
- feat(site): align docs code blocks with the landing page's VS Code themes by @igalklebanov in #1978
📦 CICD & Tooling
- chore: bump deps. by @igalklebanov in #1979
- chore: bump github actions. by @igalklebanov in #1980
⚠️ Breaking Changes
🐤 New Contributors
- @anonpay-sh made their first contribution in #1949
- @lourd made their first contribution in #1971
What's Changed
Full Changelog: v0.29.4...v0.29.5
0.30.0-beta.1
Hey 👋
0.30 season is upon us. pnpm i kysely@next and get a sneak peak into the future!
We've got a new transactionMode: 'per-run' | 'per-migration' | 'none' property you can pass to Migrator or it's methods.
'per-run'is the classic behavior you're used to wherekyselywrap the entire run in a transaction when your dialect supports transactional DDL.'per-migration'enables each migration to pick whether it runs in its own transaction or not. Just exposeconfig: { transaction: false }from the module, right next to theup/downfunctions.'none'means no transactions are used, which is similar to the now deprecateddisableTransactions: true.
import * as fs from 'node:fs/promises'
import * as path from 'node:path'
import { FileMigrationProvider, Migrator } from 'kysely/migration'
const migrator = new Migrator({
db,
provider: new FileMigrationProvider({
fs,
migrationFolder: path.join(import.meta.dirname, 'migrations'),
}),
transactionMode: 'per-migration', // <-------------------------------
})
await migrator.migrateToLatest()We've got a new defineMigration helper function that you can use to easily write your migrations and meet the contract requirements:
import { defineMigration } from 'kysely/migration'
export default defineMigration({
up: async (db) => {
// ...
},
config: { transaction: false }, // <--------------------
})You can now use mysql2/promise, where in the past it would hang forever since we only supported the callback style of mysql2 root import.
🚀 Features
- feat(migrator): add
migrateTo(name, { direction: 'Up' | 'Down' })to enforce direction. by @igalklebanov in #1957
PostgreSQL 🐘 / MSSQL 🥅
- feat: Per-migration transaction configuration by @lourd & @igalklebanov in #1671
MySQL 🐬
- feat(mysql): support both
mysql2andmysql2/promiseinMysqlDialect. by @igalklebanov in #1958
SQLite 📘
- feat: deny passing BLOB-like columns to SQLite JSON helpers by @hwisu & @igalklebanov in #1698
🐞 Bugfixes
📖 Documentation
📦 CICD & Tooling
⚠️ Breaking Changes
disableTransactionsis deprecated. Use the newtransactionMode: 'none', ortransactionMode: 'per-migration'with combination ofconfig: { transaction: false }.
SQLite 📘
- Trying to pass records with
BLOBcolumns in JSON helpers emits compile-time errors - e.g.KyselyTypeError<'SQLite does not support passing `BLOB` values to `json_object`. Cast to `TEXT`.'>
🐤 New Contributors
What's Changed
Full Changelog: 4ba0bd4...v0.30.0-beta.1