Function
loadMigration
([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, |
Tested by
no test coverage detected