diff --git a/.changeset/clean-balloons-run.md b/.changeset/clean-balloons-run.md new file mode 100644 index 0000000..ee9a929 --- /dev/null +++ b/.changeset/clean-balloons-run.md @@ -0,0 +1,5 @@ +--- +'@emigrate/cli': patch +--- + +Don't run any migrations if there's a failed migration in the migration history diff --git a/packages/cli/src/up-command.ts b/packages/cli/src/up-command.ts index 124dcb3..0be6e07 100644 --- a/packages/cli/src/up-command.ts +++ b/packages/cli/src/up-command.ts @@ -35,6 +35,10 @@ export default async function upCommand({ directory, dry, plugins = [] }: Config .map((file) => file.name); for await (const migrationHistoryEntry of storage.getHistory()) { + if (migrationHistoryEntry.status === 'failed') { + throw new Error(`Migration ${migrationHistoryEntry.name} is in a failed state, please fix it first`); + } + if (migrationFiles.includes(migrationHistoryEntry.name)) { migrationFiles.splice(migrationFiles.indexOf(migrationHistoryEntry.name), 1); } @@ -114,6 +118,9 @@ export default async function upCommand({ directory, dry, plugins = [] }: Config throw error; } } + } catch (error) { + console.error(error); + process.exitCode = 1; } finally { await cleanup(); }