MCPcopy Create free account
hub / github.com/Effect-TS/effect / loadMigration

Function loadMigration

packages/effect/src/unstable/sql/Migrator.ts:177–205  ·  view source on GitHub ↗
([id, name, load]: ResolvedMigration)

Source from the content-addressed store, hash-verified

175 )
176
177 const loadMigration = ([id, name, load]: ResolvedMigration) =>
178 Effect.catchDefect(load, (_) =>
179 Effect.fail(
180 new MigrationError({
181 kind: "ImportError",
182 message: `Could not import migration "${id}_${name}"\n\n${_}`
183 })
184 )).pipe(
185 Effect.flatMap((_) =>
186 Effect.isEffect(_)
187 ? Effect.succeed(_)
188 : _.default
189 ? Effect.succeed(_.default?.default ?? _.default)
190 : Effect.fail(
191 new MigrationError({
192 kind: "ImportError",
193 message: `Default export not found for migration "${id}_${name}"`
194 })
195 )
196 ),
197 Effect.filterOrFail(
198 Effect.isEffect,
199 () =>
200 new MigrationError({
201 kind: "ImportError",
202 message: `Default export was not an Effect for migration "${id}_${name}"`
203 })
204 )
205 )
206
207 const runMigration = (
208 id: number,

Callers 1

makeFunction · 0.85

Calls 3

pipeMethod · 0.65
failMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected