Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dbtool schema check stderr capturing #6830

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/Startup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,22 @@ class Startup @Inject()(actorSystem: ActorSystem,

val errorMessageBuilder = mutable.ListBuffer[String]()
val capturingProcessLogger =
ProcessLogger((o: String) => errorMessageBuilder.append(o), (e: String) => logger.error(e))
ProcessLogger((o: String) => errorMessageBuilder.append(o), (e: String) => errorMessageBuilder.append(e))

val result = Process("./tools/postgres/dbtool.js check-db-schema", None, "POSTGRES_URL" -> postgresUrl) ! capturingProcessLogger
if (result == 0) {
logger.info("Database schema is up to date.")
} else {
val errorMessage = errorMessageBuilder.toList.mkString("\n")
logger.error(errorMessage)
logger.error("dbtool: " + errorMessage)
slackNotificationService.warn("SQL schema mismatch", errorMessage)
}
}

private def ensurePostgresDatabase(): Unit = {
logger.info(s"Ensuring Postgres database…")
val processLogger = ProcessLogger((o: String) => logger.info(o), (e: String) => logger.error(e))
val processLogger =
ProcessLogger((o: String) => logger.info(s"dbtool: $o"), (e: String) => logger.error(s"dbtool: $e"))

// this script is copied to the stage directory in AssetCompilation
val result = Process("./tools/postgres/dbtool.js ensure-db", None, "POSTGRES_URL" -> postgresUrl) ! processLogger
Expand Down