Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 8 additions & 6 deletions internals/ci/src/cmds/db_migrate_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function DbMigrateAPI(options: { useEnvFile: boolean }) {
};

if (options.useEnvFile === false) {
console.log("Starting pg_local container");
console.log("Start pg_local container");

const pgLocalComposeFile = path.join(
paths.dockerfiles,
Expand All @@ -36,7 +36,7 @@ export async function DbMigrateAPI(options: { useEnvFile: boolean }) {
await waitForPgContainer(pgLocalComposeFile);
} else {
console.log(
"pg_local is not spanwed but we will continue as there is a change \
"pg_local is not spanwed but we will continue as there is a chance \
that some other pg instance may be running",
);
}
Expand Down Expand Up @@ -106,16 +106,18 @@ async function ensureDatabaseExists(): Promise<void> {

await client.connect();

const res = await client.query(
`SELECT datname FROM pg_catalog.pg_database WHERE datname = '${dbName}'`,
);
const res = await client.query(`
SELECT datname
FROM pg_catalog.pg_database
WHERE datname = '${dbName}'
`);

if (res.rowCount === 0) {
console.log(`Database "${dbName}" does not exist. Creating...`);
await client.query(`CREATE DATABASE "${dbName}"`);
console.log(`Database "${dbName}" created.`);
} else {
console.log(`Database "${dbName}" already exists.`);
console.log(`Database "${dbName}" does exist.`);
}

await client.end();
Expand Down