1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat(PostgreSQL): ability to switch the database, closes #432

This commit is contained in:
2023-06-13 18:10:52 +02:00
parent 9d00f58998
commit 89815bf5e7
15 changed files with 15113 additions and 33 deletions

View File

@ -154,7 +154,7 @@ export class PostgreSQLClient extends AntaresCore {
host: this._params.host,
port: this._params.port,
user: this._params.user,
database: undefined as string | undefined,
database: 'postgres' as string,
password: this._params.password,
ssl: null as mysql.SslOptions
};
@ -262,6 +262,18 @@ export class PostgreSQLClient extends AntaresCore {
return [];
}
async getDatabases () {
const { rows } = await this.raw('SELECT datname FROM pg_database WHERE datistemplate = false');
if (rows) {
return rows.reduce((acc, cur) => {
acc.push(cur.datname);
return acc;
}, [] as string[]);
}
else
return [];
}
async getStructure (schemas: Set<string>) {
/* eslint-disable camelcase */
interface ShowTableResult {