Skip to content

Commit a4f56bf

Browse files
authored
fix: improve error when creating database (#112)
1 parent d17f5b3 commit a4f56bf

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/commands/reset.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ export async function _reset(
3636
console.log(
3737
`graphile-migrate${logSuffix}: dropped database '${databaseName}'`,
3838
);
39-
await pgClient.query(
40-
`CREATE DATABASE ${escapeIdentifier(
41-
databaseName,
42-
)} OWNER ${escapeIdentifier(databaseOwner)};`,
43-
);
39+
try {
40+
await pgClient.query(
41+
`CREATE DATABASE ${escapeIdentifier(
42+
databaseName,
43+
)} OWNER ${escapeIdentifier(databaseOwner)};`,
44+
);
45+
} catch (e) {
46+
throw new Error(
47+
`Failed to create database '${databaseName}' with owner '${databaseOwner}': ${e.message}`,
48+
);
49+
}
4450
await pgClient.query(
4551
`REVOKE ALL ON DATABASE ${escapeIdentifier(databaseName)} FROM PUBLIC;`,
4652
);

0 commit comments

Comments
 (0)