Skip to content

Commit

Permalink
fix: save deployed migrations even if other migrations failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Mbanugo authored and pmbanugo committed Sep 14, 2021
1 parent 7505972 commit 3bb8f29
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/contentful/migration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { runMigration } from "contentful-migration"

import { info, success } from "../logger"
import { info, success, error } from "../logger"
import { MigrationOptions, PendingMigration } from "../types"

export type MigrationResult = {
Expand All @@ -17,9 +17,16 @@ export async function runMigrations(
for (const { filePath, fileName } of pendingMigrations) {
info(`Deploying migration ${filePath}...`)

// disable this es-lint warning because the underlying function return "any" type and we have no control over that.
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const result = await runMigration({ ...options, filePath, yes })
let result
try {
// disable this es-lint warning because the underlying function return "any" type and we have no control over that.
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
result = await runMigration({ ...options, filePath, yes })
} catch (e) {
info(`${filePath} migration failed`)
error((e as Error).message)
}

if (result) {
success(`${filePath} migration deployed`)
migrationResult.push({ successful: true, fileName })
Expand Down

0 comments on commit 3bb8f29

Please sign in to comment.