Skip to content

Commit

Permalink
fix: add database user and name to prevent errors 🛠️ (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
noel-abeje authored Apr 1, 2024
1 parent 72189c5 commit 2ed8f24
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/core/src/infrastructure/database/scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}
});
);

0 comments on commit 2ed8f24

Please sign in to comment.