mirror of
https://github.com/morten-olsen/homelab-operator.git
synced 2026-02-08 01:36:28 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
638c288a5c |
@@ -42,9 +42,9 @@ class PostgresInstance {
|
|||||||
const existingRole = await this.#db.raw('SELECT 1 FROM pg_roles WHERE rolname = ?', [role.name]);
|
const existingRole = await this.#db.raw('SELECT 1 FROM pg_roles WHERE rolname = ?', [role.name]);
|
||||||
|
|
||||||
if (existingRole.rows.length === 0) {
|
if (existingRole.rows.length === 0) {
|
||||||
await this.#db.raw(`CREATE ROLE ${role.name} WITH LOGIN PASSWORD '${role.password}'`);
|
await this.#db.raw(`CREATE ROLE "${role.name}" WITH LOGIN PASSWORD '${role.password}'`);
|
||||||
} else {
|
} else {
|
||||||
await this.#db.raw(`ALTER ROLE ${role.name} WITH PASSWORD '${role.password}'`);
|
await this.#db.raw(`ALTER ROLE "${role.name}" WITH PASSWORD '${role.password}'`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,9 +52,9 @@ class PostgresInstance {
|
|||||||
const existingDatabase = await this.#db.raw('SELECT * FROM pg_database WHERE datname = ?', [database.name]);
|
const existingDatabase = await this.#db.raw('SELECT * FROM pg_database WHERE datname = ?', [database.name]);
|
||||||
|
|
||||||
if (existingDatabase.rows.length === 0) {
|
if (existingDatabase.rows.length === 0) {
|
||||||
await this.#db.raw(`CREATE DATABASE ${database.name} OWNER ${database.owner}`);
|
await this.#db.raw(`CREATE DATABASE "${database.name}" OWNER "${database.owner}"`);
|
||||||
} else {
|
} else {
|
||||||
await this.#db.raw(`ALTER DATABASE ${database.name} OWNER TO ${database.owner}`);
|
await this.#db.raw(`ALTER DATABASE "${database.name}" OWNER TO "${database.owner}"`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user