npm / knex
knex
What changed in knex 1 to 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
7 breaking1 security32 new APIs and options1 performance2 behavior and defaults2 tooling46 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initknex 354 changes
Breaking changes 3
Type definitions no longer allow calling knex without a table name.
Unexpected combinations of statements and clause groups are prevented from executing.
Drops compatibility for Node versions below 16.
Security 1
PostgreSQL searchPath values escape double quotes to prevent SQL injection.
New APIs and options 14
Adds a connectionPool option for using an external pool.
Adds knex.migrate.before for migration operations.
Adds knex.migrate.to for migration operations.
Adds MariaDB driver support.
Adds support for returning in MariaDB.
Adds support for token-credential in MSSQL authentication.
Relevant submodules are exposed for developers to use.
The better-sqlite3 dialect supports the defaultSafeIntegers option.
Added dropUniqueIfExists.
Migration lifecycle hooks were added, allowing developers to hook into migration execution.
A validate pool option was added.
A default datetime/timestamp precision setting was added for Postgres.
Added the SIMILAR TO operator.
SQLite transactions can set the foreign_keys pragma for a transaction.
Performance 1
Optimized stream.write in MSSQL.
Fixes and other changes 35
Preserves binding order in PostgreSQL and MSSQL delete and update queries.
Fixes SQLite conditional insert/merge when inserting multiple rows.
Sets error.cause for Tarn acquire connection errors.
Fixes FOR UPDATE OF when used with an explicit schema.
Fixes _setNullableState so it respects the schema.
Makes stream postProcessResponse errors catchable with .on('error').
Fixes an unhandled error on connection timeout with stream.
Preserves PostgreSQL updateFrom binding order.
Fixes the .where type regression for invalid types.
Aliases in analytic functions are now properly escaped.
Type definitions now support Array<Buffer>, which was already supported in code.
DELETE queries support LIMIT in dialects that support it, such as MySQL, while remaining disallowed in dialects that do not.
SQLite appends a RETURNING statement when inserting an empty row.
Reverts the exports map added in #6227.
Fixes TypeScript types for update with a subquery.
The client constructor clones configuration, preventing changes from being shared through the original config object.
Corrects binding order for deletes that use a subquery join.
MySQL renameColumn now handles lowercase INFORMATION_SCHEMA keys.
Fixes SQLite DDL operations failing inside transactions.
Fixed ESM exports.
Fixed ESM types.
Added type exports.
Knex can recover from a broken connection.
Fixed handling of the <=> operator, which MySQL does not permit.
The behavior of first when there are zero matches is specified.
Fixed migrate up behavior with a completed migration.
Postgres reports a clearer error when pg-query-stream is missing.
Support for safeIntegers in better-sqlite3 was improved.
MySQL support for upsert is documented.
Fixed where queries that use a raw column.
Fixed a whereILike issue with SQLite.
Fixes migrate:unlock when used with custom identifier wrapping.
Fixes the Knex type declarations to work with mixed modules.
Fixes driver options specified with .options() being ignored for the oracledb dialect.
Fixes the typing for raw bindings.
knex 21 changes
Fixes and other changes 1
The sqlite3 package was restored.
knex 136 changes
Breaking changes 4
The Migrator consistently returns a list of migrations as objects.
Support for Node 10 was dropped.
The data structure returned by the RETURNING operation changed to be consistent with SELECT.
The unsupported sqlite3 driver was replaced with @vscode/sqlite3.
New APIs and options 18
Added a new SQLite dialect using the better-sqlite3 driver.
Added check constraints support.
Added support for creating a database table based on another table.
SQLite supports createViewOrReplace.
Added support for custom seed sources.
PostgreSQL supports JOIN and USING syntax for delete statements.
forUpdate supports an array parameter.
Added support for fromRaw.
Supports creating multiple primary keys with increments.
Added advanced JSON support.
Added support for specifying a type in a TypeScript knexfile.
Bindings can be skipped for limit and offset.
Join onIn clauses now accept Raw.
Timestamp and datetime columns support zero precision.
Added camel case support to the timestamps method.
Added support for unique constraints in MSSQL.
Added a binary UUID option.
Added support for whereLike and whereILike.
Behavior and default changes 2
Set the MySQL comment size warning limit to 1024.
View columns are optional in create view like.
Tooling 2
Improved the columnInfo type.
Updated the types for the returning method.
Fixes and other changes 10
Fixed MySQL connection validation.
Fixed createViewOrReplace.
Fixed foreign key constraints when altering a SQLite table.
The indexType accepted by index creation can be a string.
Added missing integer typings.
Fixed insertion of the lock row during migration.
SQLite supports RETURNING statements with the better-sqlite3 driver.
Fixed a syntax error involving Union all and first.
Fixed an overzealous warning when whereNot is used with in or between.
SQLite .hasTable now enables wrapIdentifier.