From 2ed8f246f5b64107a808d9246781f8ad4ca7488b Mon Sep 17 00:00:00 2001 From: noel-abeje <81399412+noel-abeje@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:24:38 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20add=20database=20user=20and=20name=20to?= =?UTF-8?q?=20prevent=20errors=20=F0=9F=9B=A0=EF=B8=8F=20(#65)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/database/scripts/setup.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/core/src/infrastructure/database/scripts/setup.ts b/packages/core/src/infrastructure/database/scripts/setup.ts index 1229f105b..d20ef9f46 100644 --- a/packages/core/src/infrastructure/database/scripts/setup.ts +++ b/packages/core/src/infrastructure/database/scripts/setup.ts @@ -14,8 +14,20 @@ const __dirname = path.dirname(__filename); // This is the full path to the `setup.sql` file. const pathToInitFile = path.join(__dirname, 'setup.sql'); -exec(`psql -f ${pathToInitFile}`, (_, stdout, stderror) => { - if (stderror) { - throw new Error(stderror); +exec( + `psql -U postgres -d postgres -f ${pathToInitFile}`, + (error, stdout, stderr) => { + if (stdout) { + console.log(stdout); + } + + if (stderr) { + // Log but don't throw for notices/warnings. + console.warn(stderr); + } + + if (error) { + throw new Error(`psql exited with error: ${error}`); + } } -}); +);