Last Updated: 3/10/2026
- DialectAdapterBase
Class DialectAdapterBaseAbstract
A basic implementation of DialectAdapter with sensible default values. Third-party dialects can extend this instead of implementing the DialectAdapter interface from scratch. That way all new settings will get default values when they are added and there will be less breaking changes.
Hierarchy (View Summary)
- DialectAdapterBase
Implements
Index
Constructors
Accessors
supportsCreateIfNotExists supportsOutput supportsReturning supportsTransactionalDdl
Methods
acquireMigrationLock releaseMigrationLock
Constructors
constructor
Accessors
supportsCreateIfNotExists
-
get supportsCreateIfNotExists(): boolean
Whether or not this dialect supports
if not existsin creation of tables/schemas/views/etc.If this is false, Kysely’s internal migrations tables and schemas are created without
if not existsin migrations. This is not a problem if the dialect supports transactional DDL.Returns boolean
supportsOutput
-
get supportsOutput(): boolean
Whether or not this dialect supports the
outputclause in inserts updates and deletes.Returns boolean
supportsReturning
-
get supportsReturning(): boolean
Whether or not this dialect supports the
returningin inserts updates and deletes.Returns boolean
supportsTransactionalDdl
-
get supportsTransactionalDdl(): boolean
Whether or not this dialect supports transactional DDL.
If this is true, migrations are executed inside a transaction.
Returns boolean
Methods
AbstractacquireMigrationLock
-
acquireMigrationLock(
db: Kysely<any>,
options: MigrationLockOptions,
): Promise<void>This method is used to acquire a lock for the migrations so that it’s not possible for two migration operations to run in parallel.
Most dialects have explicit locks that can be used, like advisory locks in PostgreSQL and the get_lock function in MySQL.
If the dialect doesn’t have explicit locks the MigrationLockOptions.lockTable created by Kysely can be used instead. You can access it through the
optionsobject. The lock table has two columnsidandis_lockedand there’s only one row in the table whose id is MigrationLockOptions.lockRowId.is_lockedis an integer. Kysely takes care of creating the lock table and inserting the one single row to it before this method is executed. If the dialect supports schemas and the user has specified a custom schema in their migration settings, the options object also contains the schema name in MigrationLockOptions.lockTableSchema.Here’s an example of how you might implement this method for a dialect that doesn’t have explicit locks but supports
FOR UPDATErow locks and transactional DDL:import { DialectAdapterBase, type MigrationLockOptions, Kysely } from 'kysely' export class MyAdapter extends DialectAdapterBase { override async acquireMigrationLock( db: Kysely< any>, options: MigrationLockOptions ): Promise< void> { const queryDb = options. lockTableSchema ? db. withSchema(options. lockTableSchema) : db // Since our imaginary dialect supports transactional DDL and has // row locks, we can simply take a row lock here and it will guarantee // all subsequent calls to this method from other transactions will // wait until this transaction finishes. await queryDb . selectFrom(options. lockTable) . selectAll() . where('id', '=', options. lockRowId) . forUpdate() . execute() } override async releaseMigrationLock() { // noop }}If
supportsTransactionalDdlistruethen thedbpassed to this method is a transaction inside which the migrations will be executed. Otherwisedbis a single connection (session) that will be used to execute the migrations.Parameters
- db: Kysely<any>
- options: MigrationLockOptions
Returns Promise<void>
AbstractreleaseMigrationLock
-
releaseMigrationLock(
db: Kysely<any>,
options: MigrationLockOptions,
): Promise<void>Releases the migration lock. See acquireMigrationLock.
If
supportsTransactionalDdlistruethen thedbpassed to this method is a transaction inside which the migrations were executed. Otherwisedbis a single connection (session) that was used to execute the migrations and theacquireMigrationLockcall.Parameters
- db: Kysely<any>
- options: MigrationLockOptions
Returns Promise<void>
Settings
Member Visibility
On This Page
Constructors
Accessors
supportsCreateIfNotExistssupportsOutputsupportsReturningsupportsTransactionalDdl
Methods