fix(cli): don't run any migrations if any previous migration have failed
This commit is contained in:
parent
3b36b3de52
commit
46b9104cda
2 changed files with 12 additions and 0 deletions
5
.changeset/clean-balloons-run.md
Normal file
5
.changeset/clean-balloons-run.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@emigrate/cli': patch
|
||||
---
|
||||
|
||||
Don't run any migrations if there's a failed migration in the migration history
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue