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