Skip to content

Commit

Permalink
fix: exit code for failed migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Oct 29, 2023
1 parent 7f4d1ff commit a4d261e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/many-windows-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kysely-migrate": patch
---

Updated exit code for failed migrations
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions src/commands/down.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions src/commands/to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions src/commands/up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit a4d261e

Please sign in to comment.