Skip to content

v0.30.0-beta.2

Pre-release
Pre-release

Choose a tag to compare

@igalklebanov igalklebanov released this 14 Sep 01:34
· 0 commits to master since this release
Immutable release. Only release title and notes can be modified.
4f5fc83

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 where kysely wrap 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 expose config: { transaction: false } from the module, right next to the up/down functions.
  • 'none' means no transactions are used, which is similar to the now deprecated disableTransactions: 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

PostgreSQL 🐘 / MSSQL πŸ₯…

PostgreSQL 🐘

MySQL 🐬

  • feat(mysql): support both mysql2 and mysql2/promise in MysqlDialect. by @igalklebanov in #1958
  • feat(mysql): add withNonDefaultDatabases to support introspection of non-default databases. by @igalklebanov in #2007

SQLite πŸ“˜

🐞 Bugfixes

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

  • disableTransactions is deprecated. Use the new transactionMode: 'none', or transactionMode: 'per-migration' with combination of config: { transaction: false }.
  • MySQL introspection now always excludes system databases - mysql, information_schema, performance_schema, sys and nbinfo tables will not be returned.
  • You might start seeing invocations of some your custom helpers failing compilation now that Kysely, Transaction, ControlledTransaction and their readonly variants are compared more tightly. QueryCreator, FunctionModule, MergeQueryBuilder too. Please report these cases.

SQLite πŸ“˜

  • Trying to pass records with BLOB columns 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