Skip to content

Commit a4d261e

Browse files
committed
fix: exit code for failed migrations
1 parent 7f4d1ff commit a4d261e

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

.changeset/many-windows-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"kysely-migrate": patch
3+
---
4+
5+
Updated exit code for failed migrations

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ try {
8989
if (result) outro(result)
9090
process.exit(0)
9191
} catch (error) {
92-
outro(pc.red(`Error: ${(error as Error).message}`))
92+
outro(pc.red((error as Error).message))
9393
process.exit(1)
9494
}

src/commands/down.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,7 @@ export async function down(options: DownOptions) {
6060
s.stop('Ran migrations', error ? 1 : 0)
6161

6262
logResultSet(resultSet)
63+
64+
if (error) throw new Error('Failed running migrations.')
6365
return getAppliedMigrationsCount(results)
6466
}

src/commands/to.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ export async function to(options: ToOptions) {
7777
s.stop('Ran migrations', error ? 1 : 0)
7878

7979
logResultSet(resultSet)
80+
81+
if (error) throw new Error('Failed running migrations.')
8082
return getAppliedMigrationsCount(results)
8183
}

src/commands/up.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ export async function up(options: UpOptions) {
4141
s.stop('Ran migrations', error ? 1 : 0)
4242

4343
logResultSet(resultSet)
44+
45+
if (error) throw new Error('Failed running migrations.')
4446
return getAppliedMigrationsCount(results)
4547
}

0 commit comments

Comments
 (0)