feat: support custom db schema (#6670)

* feat: db schema

* apply suggestion

Co-authored-by: Tom Moor <tom.moor@gmail.com>

* fix linter

---------

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Axel Rindle
2024-03-15 14:08:12 +01:00
committed by GitHub
parent 1a386c9900
commit 34c2c5fd51
2 changed files with 8 additions and 0 deletions

View File

@@ -80,6 +80,12 @@ export class Environment {
})
public DATABASE_URL = environment.DATABASE_URL ?? "";
/**
* An optional database schema.
*/
@IsOptional()
public DATABASE_SCHEMA = this.toOptionalString(environment.DATABASE_SCHEMA);
/**
* The url of the database pool.
*/

View File

@@ -11,6 +11,7 @@ const isSSLDisabled = env.PGSSLMODE === "disable";
const poolMax = env.DATABASE_CONNECTION_POOL_MAX ?? 5;
const poolMin = env.DATABASE_CONNECTION_POOL_MIN ?? 0;
const url = env.DATABASE_CONNECTION_POOL_URL || env.DATABASE_URL;
const schema = env.DATABASE_SCHEMA;
export function createDatabaseInstance(
url: string,
@@ -42,6 +43,7 @@ export function createDatabaseInstance(
acquire: 30000,
idle: 10000,
},
schema,
});
}