@effect/sql-sqlite-bun 4.0.0-beta.70 → 4.0.0-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SqliteClient.d.ts.map +1 -1
- package/dist/SqliteClient.js +39 -13
- package/dist/SqliteClient.js.map +1 -1
- package/dist/index.d.ts +0 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -37
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/SqliteClient.ts +39 -13
- package/src/index.ts +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAEvD,OAAO,EAAuB,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAQ5E;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,MAA+C,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,sCAAsC,CAAA;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,SAAS;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC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,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAUzB,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAChB,QAAQ,kBAAkB,KACzB,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAML,CAAA"}
|
package/dist/SqliteClient.js
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
|
|
3
3
|
*
|
|
4
|
-
* This module provides
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* This module provides the Bun-specific SQLite driver used by Effect SQL. It
|
|
5
|
+
* can create a scoped {@link SqliteClient} directly with {@link make}, or
|
|
6
|
+
* provide both the SQLite-specific client and the generic `SqlClient` service
|
|
7
|
+
* with {@link layer} or {@link layerConfig}. It is intended for Bun
|
|
8
|
+
* applications, local tools, migrations, integration tests, and embedded
|
|
9
|
+
* persistence that use file-backed or in-memory SQLite databases.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
11
|
+
* ## Mental model
|
|
12
|
+
*
|
|
13
|
+
* A client owns one scoped `bun:sqlite` `Database` handle. Because Bun's SQLite
|
|
14
|
+
* API executes statements synchronously, this implementation serializes access
|
|
15
|
+
* to that handle. A transaction keeps the serialized connection permit for the
|
|
16
|
+
* transaction scope, so other fibers using the same client wait until the
|
|
17
|
+
* transaction completes.
|
|
18
|
+
*
|
|
19
|
+
* The client uses the Effect SQL statement compiler and result-name transforms,
|
|
20
|
+
* then adds SQLite-specific capabilities such as database export and native
|
|
21
|
+
* extension loading.
|
|
22
|
+
*
|
|
23
|
+
* ## Common tasks
|
|
24
|
+
*
|
|
25
|
+
* - Use {@link layer} when a Bun service should provide both `SqliteClient` and
|
|
26
|
+
* the generic `SqlClient` from a concrete configuration.
|
|
27
|
+
* - Use {@link layerConfig} when the filename or open flags should come from
|
|
28
|
+
* Effect `Config`.
|
|
29
|
+
* - Use {@link make} inside a custom scoped layer when the surrounding runtime
|
|
30
|
+
* needs to manage the client lifecycle explicitly.
|
|
31
|
+
* - Use `client.export` to serialize the database, or `client.loadExtension` to
|
|
32
|
+
* load a native SQLite extension.
|
|
33
|
+
*
|
|
34
|
+
* ## Gotchas
|
|
35
|
+
*
|
|
36
|
+
* WAL mode is enabled by default. Set `disableWAL` for read-only databases or
|
|
37
|
+
* when the database file or directory cannot be updated with SQLite WAL side
|
|
38
|
+
* files. Separate database handles or processes can still contend for SQLite
|
|
39
|
+
* write locks even though access through a single client is serialized.
|
|
40
|
+
*
|
|
41
|
+
* Safe integer handling follows the generic `SqlClient` fiber-local setting.
|
|
42
|
+
* `executeStream` is not implemented for this driver, and SQLite does not
|
|
43
|
+
* support `updateValues`.
|
|
18
44
|
*
|
|
19
45
|
* @since 4.0.0
|
|
20
46
|
*/
|
package/dist/SqliteClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.js","names":["Database","Config","Context","Effect","Fiber","identity","Layer","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","SqliteClient","Service","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","filename","readonly","readwrite","create","addFinalizer","sync","close","disableWAL","run","sql","params","withFiber","fiber","statement","query","useSafeIntegers","get","context","SafeIntegers","safeIntegers","succeed","all","fail","reason","runValues","values","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","_sql","_params","die","export","try","serialize","catch","loadExtension","path","semaphore","connection","acquirer","withPermits","transactionAcquirer","uninterruptibleMask","restore","getCurrent","scope","getUnsafe","as","tap","take","release","Object","assign","spanAttributes","entries","config","flatMap","_","layerConfig","effectContext","unwrap","pipe","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SqliteClient.js","names":["Database","Config","Context","Effect","Fiber","identity","Layer","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","SqliteClient","Service","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","filename","readonly","readwrite","create","addFinalizer","sync","close","disableWAL","run","sql","params","withFiber","fiber","statement","query","useSafeIntegers","get","context","SafeIntegers","safeIntegers","succeed","all","fail","reason","runValues","values","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","_sql","_params","die","export","try","serialize","catch","loadExtension","path","semaphore","connection","acquirer","withPermits","transactionAcquirer","uninterruptibleMask","restore","getCurrent","scope","getUnsafe","as","tap","take","release","Object","assign","spanAttributes","entries","config","flatMap","_","layerConfig","effectContext","unwrap","pipe","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAASA,QAAQ,QAAQ,YAAY;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,uCAAuC;AACnE,OAAO,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@
|
|
|
2
2
|
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
|
|
6
|
-
*
|
|
7
|
-
* This module provides constructors and layers for using a Bun-managed SQLite database as both the
|
|
8
|
-
* SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
|
|
9
|
-
* file-backed or in-memory databases in Bun applications, local development tools, migrations,
|
|
10
|
-
* integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
|
|
11
|
-
* SQLite-specific helpers such as database export and native extension loading.
|
|
12
|
-
*
|
|
13
|
-
* Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
|
|
14
|
-
* is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
|
|
15
|
-
* so set `disableWAL` when opening read-only databases or when the database file or directory cannot
|
|
16
|
-
* be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
|
|
17
|
-
* the transaction scope, so concurrent fibers using the same client wait until it completes, while
|
|
18
|
-
* separate database handles or processes can still contend for SQLite write locks. Safe integer
|
|
19
|
-
* handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
|
|
20
|
-
* SQLite does not support `updateValues`.
|
|
21
|
-
*
|
|
22
5
|
* @since 4.0.0
|
|
23
6
|
*/
|
|
24
7
|
export * as SqliteClient from "./SqliteClient.ts";
|
|
25
8
|
/**
|
|
26
|
-
* Utilities for applying Effect SQL migrations to Bun SQLite databases.
|
|
27
|
-
*
|
|
28
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
29
|
-
* provides `run` and `layer` helpers for applying ordered migrations through
|
|
30
|
-
* the current Bun-backed SQLite `SqlClient`. It is typically used at
|
|
31
|
-
* application startup, in deployment or setup scripts that prepare a local
|
|
32
|
-
* SQLite file, in integration tests with temporary database files, or in layer
|
|
33
|
-
* graphs that must install the schema before dependent services are acquired.
|
|
34
|
-
*
|
|
35
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
36
|
-
* using the shared `<id>_<name>` file or record-key convention. Only migrations
|
|
37
|
-
* with an id greater than the latest recorded id are applied, so every client
|
|
38
|
-
* involved in startup should point at the same SQLite filename and use a
|
|
39
|
-
* writable Bun SQLite configuration. The Bun client enables WAL by default and
|
|
40
|
-
* serializes access through a single `bun:sqlite` database handle, but separate
|
|
41
|
-
* handles or processes can still contend for SQLite write locks. Bun's SQLite
|
|
42
|
-
* driver runs statements synchronously, so large migration sets can block the
|
|
43
|
-
* invoking runtime thread, and this adapter does not currently write SQLite
|
|
44
|
-
* schema dumps for `schemaDirectory`.
|
|
45
|
-
*
|
|
46
9
|
* @since 4.0.0
|
|
47
10
|
*/
|
|
48
11
|
export * as SqliteMigrator from "./SqliteMigrator.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,47 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
5
|
/**
|
|
6
|
-
* Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
|
|
7
|
-
*
|
|
8
|
-
* This module provides constructors and layers for using a Bun-managed SQLite database as both the
|
|
9
|
-
* SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
|
|
10
|
-
* file-backed or in-memory databases in Bun applications, local development tools, migrations,
|
|
11
|
-
* integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
|
|
12
|
-
* SQLite-specific helpers such as database export and native extension loading.
|
|
13
|
-
*
|
|
14
|
-
* Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
|
|
15
|
-
* is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
|
|
16
|
-
* so set `disableWAL` when opening read-only databases or when the database file or directory cannot
|
|
17
|
-
* be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
|
|
18
|
-
* the transaction scope, so concurrent fibers using the same client wait until it completes, while
|
|
19
|
-
* separate database handles or processes can still contend for SQLite write locks. Safe integer
|
|
20
|
-
* handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
|
|
21
|
-
* SQLite does not support `updateValues`.
|
|
22
|
-
*
|
|
23
6
|
* @since 4.0.0
|
|
24
7
|
*/
|
|
25
8
|
export * as SqliteClient from "./SqliteClient.js";
|
|
26
9
|
/**
|
|
27
|
-
* Utilities for applying Effect SQL migrations to Bun SQLite databases.
|
|
28
|
-
*
|
|
29
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
30
|
-
* provides `run` and `layer` helpers for applying ordered migrations through
|
|
31
|
-
* the current Bun-backed SQLite `SqlClient`. It is typically used at
|
|
32
|
-
* application startup, in deployment or setup scripts that prepare a local
|
|
33
|
-
* SQLite file, in integration tests with temporary database files, or in layer
|
|
34
|
-
* graphs that must install the schema before dependent services are acquired.
|
|
35
|
-
*
|
|
36
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
37
|
-
* using the shared `<id>_<name>` file or record-key convention. Only migrations
|
|
38
|
-
* with an id greater than the latest recorded id are applied, so every client
|
|
39
|
-
* involved in startup should point at the same SQLite filename and use a
|
|
40
|
-
* writable Bun SQLite configuration. The Bun client enables WAL by default and
|
|
41
|
-
* serializes access through a single `bun:sqlite` database handle, but separate
|
|
42
|
-
* handles or processes can still contend for SQLite write locks. Bun's SQLite
|
|
43
|
-
* driver runs statements synchronously, so large migration sets can block the
|
|
44
|
-
* invoking runtime thread, and this adapter does not currently write SQLite
|
|
45
|
-
* schema dumps for `schemaDirectory`.
|
|
46
|
-
*
|
|
47
10
|
* @since 4.0.0
|
|
48
11
|
*/
|
|
49
12
|
export * as SqliteMigrator from "./SqliteMigrator.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["SqliteClient","SqliteMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA
|
|
1
|
+
{"version":3,"file":"index.js","names":["SqliteClient","SqliteMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAKA,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-sqlite-bun",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.71",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A SQLite toolkit for Effect",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/bun": "^1.3.13",
|
|
47
|
-
"@effect/platform-bun": "^4.0.0-beta.
|
|
48
|
-
"effect": "^4.0.0-beta.
|
|
47
|
+
"@effect/platform-bun": "^4.0.0-beta.71",
|
|
48
|
+
"effect": "^4.0.0-beta.71"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"effect": "^4.0.0-beta.
|
|
51
|
+
"effect": "^4.0.0-beta.71"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"codegen": "effect-utils codegen",
|
package/src/SqliteClient.ts
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
|
|
3
3
|
*
|
|
4
|
-
* This module provides
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* This module provides the Bun-specific SQLite driver used by Effect SQL. It
|
|
5
|
+
* can create a scoped {@link SqliteClient} directly with {@link make}, or
|
|
6
|
+
* provide both the SQLite-specific client and the generic `SqlClient` service
|
|
7
|
+
* with {@link layer} or {@link layerConfig}. It is intended for Bun
|
|
8
|
+
* applications, local tools, migrations, integration tests, and embedded
|
|
9
|
+
* persistence that use file-backed or in-memory SQLite databases.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
11
|
+
* ## Mental model
|
|
12
|
+
*
|
|
13
|
+
* A client owns one scoped `bun:sqlite` `Database` handle. Because Bun's SQLite
|
|
14
|
+
* API executes statements synchronously, this implementation serializes access
|
|
15
|
+
* to that handle. A transaction keeps the serialized connection permit for the
|
|
16
|
+
* transaction scope, so other fibers using the same client wait until the
|
|
17
|
+
* transaction completes.
|
|
18
|
+
*
|
|
19
|
+
* The client uses the Effect SQL statement compiler and result-name transforms,
|
|
20
|
+
* then adds SQLite-specific capabilities such as database export and native
|
|
21
|
+
* extension loading.
|
|
22
|
+
*
|
|
23
|
+
* ## Common tasks
|
|
24
|
+
*
|
|
25
|
+
* - Use {@link layer} when a Bun service should provide both `SqliteClient` and
|
|
26
|
+
* the generic `SqlClient` from a concrete configuration.
|
|
27
|
+
* - Use {@link layerConfig} when the filename or open flags should come from
|
|
28
|
+
* Effect `Config`.
|
|
29
|
+
* - Use {@link make} inside a custom scoped layer when the surrounding runtime
|
|
30
|
+
* needs to manage the client lifecycle explicitly.
|
|
31
|
+
* - Use `client.export` to serialize the database, or `client.loadExtension` to
|
|
32
|
+
* load a native SQLite extension.
|
|
33
|
+
*
|
|
34
|
+
* ## Gotchas
|
|
35
|
+
*
|
|
36
|
+
* WAL mode is enabled by default. Set `disableWAL` for read-only databases or
|
|
37
|
+
* when the database file or directory cannot be updated with SQLite WAL side
|
|
38
|
+
* files. Separate database handles or processes can still contend for SQLite
|
|
39
|
+
* write locks even though access through a single client is serialized.
|
|
40
|
+
*
|
|
41
|
+
* Safe integer handling follows the generic `SqlClient` fiber-local setting.
|
|
42
|
+
* `executeStream` is not implemented for this driver, and SQLite does not
|
|
43
|
+
* support `updateValues`.
|
|
18
44
|
*
|
|
19
45
|
* @since 4.0.0
|
|
20
46
|
*/
|
package/src/index.ts
CHANGED
|
@@ -5,48 +5,11 @@
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
|
|
9
|
-
*
|
|
10
|
-
* This module provides constructors and layers for using a Bun-managed SQLite database as both the
|
|
11
|
-
* SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
|
|
12
|
-
* file-backed or in-memory databases in Bun applications, local development tools, migrations,
|
|
13
|
-
* integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
|
|
14
|
-
* SQLite-specific helpers such as database export and native extension loading.
|
|
15
|
-
*
|
|
16
|
-
* Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
|
|
17
|
-
* is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
|
|
18
|
-
* so set `disableWAL` when opening read-only databases or when the database file or directory cannot
|
|
19
|
-
* be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
|
|
20
|
-
* the transaction scope, so concurrent fibers using the same client wait until it completes, while
|
|
21
|
-
* separate database handles or processes can still contend for SQLite write locks. Safe integer
|
|
22
|
-
* handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
|
|
23
|
-
* SQLite does not support `updateValues`.
|
|
24
|
-
*
|
|
25
8
|
* @since 4.0.0
|
|
26
9
|
*/
|
|
27
10
|
export * as SqliteClient from "./SqliteClient.ts"
|
|
28
11
|
|
|
29
12
|
/**
|
|
30
|
-
* Utilities for applying Effect SQL migrations to Bun SQLite databases.
|
|
31
|
-
*
|
|
32
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
33
|
-
* provides `run` and `layer` helpers for applying ordered migrations through
|
|
34
|
-
* the current Bun-backed SQLite `SqlClient`. It is typically used at
|
|
35
|
-
* application startup, in deployment or setup scripts that prepare a local
|
|
36
|
-
* SQLite file, in integration tests with temporary database files, or in layer
|
|
37
|
-
* graphs that must install the schema before dependent services are acquired.
|
|
38
|
-
*
|
|
39
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
40
|
-
* using the shared `<id>_<name>` file or record-key convention. Only migrations
|
|
41
|
-
* with an id greater than the latest recorded id are applied, so every client
|
|
42
|
-
* involved in startup should point at the same SQLite filename and use a
|
|
43
|
-
* writable Bun SQLite configuration. The Bun client enables WAL by default and
|
|
44
|
-
* serializes access through a single `bun:sqlite` database handle, but separate
|
|
45
|
-
* handles or processes can still contend for SQLite write locks. Bun's SQLite
|
|
46
|
-
* driver runs statements synchronously, so large migration sets can block the
|
|
47
|
-
* invoking runtime thread, and this adapter does not currently write SQLite
|
|
48
|
-
* schema dumps for `schemaDirectory`.
|
|
49
|
-
*
|
|
50
13
|
* @since 4.0.0
|
|
51
14
|
*/
|
|
52
15
|
export * as SqliteMigrator from "./SqliteMigrator.ts"
|