fix: Account for non-SSL database connection in pending migrations check (#3811)

* fix: Account for non-SSL database connection in pending migrations check

* Double exit
This commit is contained in:
Tom Moor
2022-07-19 09:58:48 +01:00
committed by GitHub
parent 9cafe75bf2
commit 9ab409a640

View File

@@ -6,7 +6,12 @@ import AuthenticationProvider from "@server/models/AuthenticationProvider";
import Team from "@server/models/Team";
export function checkPendingMigrations() {
const commandResult = execSync("yarn sequelize db:migrate:status");
try {
const commandResult = execSync(
`yarn sequelize db:migrate:status${
env.PGSSLMODE === "disable" ? " --env=production-ssl-disabled" : ""
}`
);
const commandResultArray = Buffer.from(commandResult)
.toString("utf-8")
.split("\n");
@@ -26,6 +31,16 @@ export function checkPendingMigrations() {
"Please run `yarn db:migrate` or `yarn db:migrate --env production-ssl-disabled` to run all pending migrations"
);
process.exit(1);
}
} catch (err) {
if (err.message.includes("ECONNREFUSED")) {
Logger.warn(
`Could not connect to the database. Please check your connection settings.`
);
} else {
Logger.warn(err.message);
}
process.exit(1);
}
}