| ... | ... | @@ -92,19 +92,20 @@ export interface RunMigrationsOptions { |
| 92 | 92 | * |
| 93 | 93 | * @returns Effect containing array of executed migrations |
| 94 | 94 | */ |
| 95 | | export const runMigrations = ({ toMigrationInclusive }: RunMigrationsOptions = {}) => |
| 96 | | Effect.gen(function* () { |
| 97 | | yield* Effect.log( |
| 98 | | toMigrationInclusive === undefined |
| 99 | | ? "Running all migrations..." |
| 100 | | : `Running migrations 1 through ${toMigrationInclusive}...`, |
| 101 | | ); |
| 102 | | const executedMigrations = yield* run({ loader: makeMigrationLoader(toMigrationInclusive) }); |
| 103 | | yield* Effect.log("Migrations ran successfully").pipe( |
| 104 | | Effect.annotateLogs({ migrations: executedMigrations.map(([id, name]) => `${id}_${name}`) }), |
| 105 | | ); |
| 106 | | return executedMigrations; |
| 107 | | }); |
| 95 | export const runMigrations = Effect.fn("runMigrations")(function* ({ |
| 96 | toMigrationInclusive, |
| 97 | }: RunMigrationsOptions = {}) { |
| 98 | yield* Effect.log( |
| 99 | toMigrationInclusive === undefined |
| 100 | ? "Running all migrations..." |
| 101 | : `Running migrations 1 through ${toMigrationInclusive}...`, |
| 102 | ); |
| 103 | const executedMigrations = yield* run({ loader: makeMigrationLoader(toMigrationInclusive) }); |
| 104 | yield* Effect.log("Migrations ran successfully").pipe( |
| 105 | Effect.annotateLogs({ migrations: executedMigrations.map(([id, name]) => `${id}_${name}`) }), |
| 106 | ); |
| 107 | return executedMigrations; |
| 108 | }); |
| 108 | 109 | |
| 109 | 110 | /** |
| 110 | 111 | * Layer that runs migrations when the layer is built. |