The best way to control Claude Code, Codex and more from any computer or phone
| 1 | /** |
| 2 | * libSQL migration support for Effect SQL applications. |
| 3 | * |
| 4 | * This module adapts the shared SQL migrator to libSQL. It re-exports the |
| 5 | * common migration loaders and errors, then provides {@link run} and |
| 6 | * {@link layer} helpers that apply pending migrations with the current |
| 7 | * libSQL-backed `SqlClient`. `run` returns the applied migration IDs and names, |
| 8 | * while `layer` runs migrations during layer construction and provides no |
| 9 | * services. |
| 10 | * |
| 11 | * @stability unstable |
| 12 | * @since 4.0.0 |
| 13 | */ |
| 14 | import type * as Effect from "effect/Effect" |
| 15 | import * as Layer from "effect/Layer" |
| 16 | import * as Migrator from "effect/sql/Migrator" |
| 17 | import type * as Client from "effect/sql/SqlClient" |
| 18 | import type { SqlError } from "effect/sql/SqlError" |
| 19 | |
| 20 | /** |
| 21 | * @since 4.0.0 |
| 22 | */ |
| 23 | export * from "effect/sql/Migrator" |
| 24 | export { |
| 25 | /** |
| 26 | * @stability unstable |
| 27 | * @category loaders |
| 28 | * @since 4.0.0 |
| 29 | */ |
| 30 | fromFileSystem |
| 31 | } from "effect/sql/MigratorFileSystem" |
| 32 | |
| 33 | /** |
| 34 | * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied. |
| 35 | * |
| 36 | * @stability unstable |
| 37 | * @category running |
| 38 | * @since 4.0.0 |
| 39 | */ |
| 40 | export const run: <R2 = never>( |
| 41 | options: Migrator.MigratorOptions<R2> |
| 42 | ) => Effect.Effect< |
| 43 | ReadonlyArray<readonly [id: number, name: string]>, |
| 44 | Migrator.MigrationError | SqlError, |
| 45 | Client.SqlClient | R2 |
| 46 | > = Migrator.make({}) |
| 47 | |
| 48 | /** |
| 49 | * Creates a layer that runs the configured SQL migrations during layer construction. |
| 50 | * |
| 51 | * @stability unstable |
| 52 | * @category layers |
| 53 | * @since 4.0.0 |
| 54 | */ |
| 55 | export const layer = <R>( |
| 56 | options: Migrator.MigratorOptions<R> |
| 57 | ): Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R> => Layer.effectDiscard(run(options)) |