-
Notifications
You must be signed in to change notification settings - Fork 279
/
dialect-adapter.ts
54 lines (50 loc) · 2.14 KB
/
dialect-adapter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Kysely } from '../kysely.js'
/**
* A `DialectAdapter` encapsulates all differences between dialects outside
* of `Driver` and `QueryCompiler`.
*
* For example, some databases support transactional DDL and therefore we want
* to run migrations inside a transaction, while other databases don't support
* it. For that there's a `supportsTransactionalDdl` boolean in this interface.
*/
export interface DialectAdapter {
/**
* Whether or not this dialect supports transactional DDL.
*
* If this is true, migrations are executed inside a transaction.
*/
readonly supportsTransactionalDdl: boolean
/**
* Whether or not this dialect supports the `returning` in inserts
* updates and deletes.
*/
readonly supportsReturning: boolean
/**
* This method is used to acquire a lock for the migrations so that
* it's not possible for two migration processes to run in parallel.
*
* Most dialects have explicit locks that can be used, like advisory locks
* in postgres and the get_lock function in mysql.
*
* If the dialect doesn't have explicit locks the {@link MIGRATION_LOCK_TABLE}
* created by Kysely can be used instead. {@link MIGRATION_LOCK_TABLE}
* has two columns `id` and `is_locked` and there's only one row in the
* table whose id is {@link MIGRATION_LOCK_ID}. `is_locked` is an integer.
* Kysely takes care of creating the lock table and inserting the one single
* row to it before this method is executed.
*
* If `supportsTransactionalDdl` is `true` then the `db` passed to this method
* is a transaction inside which the migrations will be executed. Otherwise
* `db` is a single connection (session) that will be used to execute the
* migrations.
*/
acquireMigrationLock(db: Kysely<any>): Promise<void>
/**
* Releases the migration lock. See {@link acquireMigrationLock}.
*
* If `supportsTransactionalDdl` is `true` then the `db` passed to this method
* is a transaction inside which the migrations were executed. Otherwise `db`
* is a single connection (session) that was used to execute the migrations.
*/
releaseMigrationLock(db: Kysely<any>): Promise<void>
}