The best way to control Claude Code, Codex and more from any computer or phone

main
ts 56 lines 1.59 KB
Raw
1 /**
2 * Utilities for applying Effect SQL migrations to Microsoft SQL Server.
3 *
4 * This module re-exports the shared `Migrator` loaders and error types, then
5 * provides `run` and `layer` helpers for applying ordered migrations through
6 * the current SQL Server `SqlClient`. `run` returns the applied migration IDs
7 * and names, while `layer` runs migrations during layer construction and
8 * provides no services.
9 *
10 * @stability unstable
11 * @since 4.0.0
12 */
13 import type * as Effect from "effect/Effect"
14 import * as Layer from "effect/Layer"
15 import * as Migrator from "effect/sql/Migrator"
16 import type * as Client from "effect/sql/SqlClient"
17 import type { SqlError } from "effect/sql/SqlError"
18
19 /**
20 * @since 4.0.0
21 */
22 export * from "effect/sql/Migrator"
23 export {
24 /**
25 * @stability unstable
26 * @category loaders
27 * @since 4.0.0
28 */
29 fromFileSystem
30 } from "effect/sql/MigratorFileSystem"
31
32 /**
33 * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
34 *
35 * @stability unstable
36 * @category running
37 * @since 4.0.0
38 */
39 export const run: <R>(
40 options: Migrator.MigratorOptions<R>
41 ) => Effect.Effect<
42 ReadonlyArray<readonly [id: number, name: string]>,
43 SqlError | Migrator.MigrationError,
44 Client.SqlClient | R
45 > = Migrator.make({})
46
47 /**
48 * Creates a layer that runs the configured SQL migrations during layer construction.
49 *
50 * @stability unstable
51 * @category layers
52 * @since 4.0.0
53 */
54 export const layer = <R>(
55 options: Migrator.MigratorOptions<R>
56 ): Layer.Layer<never, SqlError | Migrator.MigrationError, Client.SqlClient | R> => Layer.effectDiscard(run(options))