diff --git a/.changeset/many-windows-search.md b/.changeset/many-windows-search.md new file mode 100644 index 0000000..9cdf01f --- /dev/null +++ b/.changeset/many-windows-search.md @@ -0,0 +1,5 @@ +--- +"kysely-migrate": patch +--- + +Updated exit code for failed migrations diff --git a/src/cli.ts b/src/cli.ts index 4b8fa27..1c539bb 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -89,6 +89,6 @@ try { if (result) outro(result) process.exit(0) } catch (error) { - outro(pc.red(`Error: ${(error as Error).message}`)) + outro(pc.red((error as Error).message)) process.exit(1) } diff --git a/src/commands/down.ts b/src/commands/down.ts index cb6ecd4..b0cf92b 100644 --- a/src/commands/down.ts +++ b/src/commands/down.ts @@ -60,5 +60,7 @@ export async function down(options: DownOptions) { s.stop('Ran migrations', error ? 1 : 0) logResultSet(resultSet) + + if (error) throw new Error('Failed running migrations.') return getAppliedMigrationsCount(results) } diff --git a/src/commands/to.ts b/src/commands/to.ts index 2646d3e..a150477 100644 --- a/src/commands/to.ts +++ b/src/commands/to.ts @@ -77,5 +77,7 @@ export async function to(options: ToOptions) { s.stop('Ran migrations', error ? 1 : 0) logResultSet(resultSet) + + if (error) throw new Error('Failed running migrations.') return getAppliedMigrationsCount(results) } diff --git a/src/commands/up.ts b/src/commands/up.ts index e07cf75..25d63ca 100644 --- a/src/commands/up.ts +++ b/src/commands/up.ts @@ -41,5 +41,7 @@ export async function up(options: UpOptions) { s.stop('Ran migrations', error ? 1 : 0) logResultSet(resultSet) + + if (error) throw new Error('Failed running migrations.') return getAppliedMigrationsCount(results) }