<R>(options: Migrator.MigratorOptions<R>): Layer.Layer<
never,
Migrator.MigrationError | SqlError,
Client.SqlClient | R
>Creates a layer that runs the configured SQLite migrations during layer construction and provides no services.
export const const layer: <R>(
options: Migrator.MigratorOptions<R>
) => Layer.Layer<
never,
Migrator.MigrationError | SqlError,
Client.SqlClient | R
>
Creates a layer that runs the configured SQLite migrations during layer construction and provides no services.
layer = <function (type parameter) R in <R>(options: Migrator.MigratorOptions<R>): Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R>R>(
options: Migrator.MigratorOptions<R>(parameter) options: {
loader: Loader<R>;
schemaDirectory: string;
table: string;
}
options: import MigratorMigrator.interface MigratorOptions<R = never>Options for running SQL migrations, including the migration loader, optional
schema dump directory, and migrations table name.
MigratorOptions<function (type parameter) R in <R>(options: Migrator.MigratorOptions<R>): Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R>R>
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<
never,
import MigratorMigrator.class MigrationErrorclass MigrationError {
name: string;
message: string;
stack: string;
cause: unknown;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
_tag: Tag;
kind: 'BadState' | 'ImportError' | 'Failed' | 'Duplicates' | 'Locked';
}
Error raised while loading, validating, locking, or running SQL migrations.
MigrationError | class SqlErrorclass SqlError {
cause: ConnectionError | AuthenticationError | AuthorizationError | SqlSyntaxError | UniqueViolation | ConstraintError | DeadlockError | SerializationError | LockTimeoutError | StatementTimeoutError | UnknownError;
message: string;
isRetryable: boolean;
_tag: 'SqlError';
reason: ConnectionError | AuthenticationError | AuthorizationError | SqlSyntaxError | UniqueViolation | ConstraintError | DeadlockError | SerializationError | LockTimeoutError | StatementTimeoutError | UnknownError;
name: string;
stack: string;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Error wrapper for SQL failures whose message, cause, and isRetryable
values are derived from its SqlErrorReason.
SqlError,
import ClientClient.SqlClient | function (type parameter) R in <R>(options: Migrator.MigratorOptions<R>): Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R>R
> => import LayerLayer.const effectDiscard: <X, E, R>(
effect: Effect<X, E, R>
) => Layer<never, E, Exclude<R, Scope.Scope>>
Constructs a layer from an effect, discarding its value and providing no
services.
When to use
Use when layer construction should run an Effect for its side effects while providing no
services.
Example (Running an effect during layer construction)
import { Effect, Layer } from "effect"
const initLayer = Layer.effectDiscard(
Effect.sync(() => {
console.log("Initializing application...")
})
)
effectDiscard(const run: <R2 = never>(
options: Migrator.MigratorOptions<R2>
) => Effect.Effect<
ReadonlyArray<
readonly [id: number, name: string]
>,
Migrator.MigrationError | SqlError,
Client.SqlClient | R2
>
Runs SQL migrations for a SQLite database using the shared Migrator implementation and the current SqlClient.
run(options: Migrator.MigratorOptions<R>(parameter) options: {
loader: Loader<R>;
schemaDirectory: string;
table: string;
}
options))