1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat: Add support for explicitly set database version. (#654)

Co-authored-by: Mathias Åhsberg <mathias.ahsberg@resurs.se>
This commit is contained in:
Mathias Åhsberg 2020-11-20 11:37:56 +01:00 committed by GitHub
parent 3db40d012a
commit 144e832cdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 1 deletions

View File

@ -47,9 +47,10 @@ Available unleash options include:
- _user_ - the database username (`DATABASE_USERNAME`) - _user_ - the database username (`DATABASE_USERNAME`)
- _password_ - the database password (`DATABASE_PASSWORD`) - _password_ - the database password (`DATABASE_PASSWORD`)
- _host_ - the database hostname (`DATABASE_HOST`) - _host_ - the database hostname (`DATABASE_HOST`)
- _port_ - the datbase port defaults to 5432 (`DATABASE_PORT`) - _port_ - the database port defaults to 5432 (`DATABASE_PORT`)
- _database_ - the database name to be used (`DATABASE_NAME`) - _database_ - the database name to be used (`DATABASE_NAME`)
- _ssl_ - an object describing ssl options, see https://node-postgres.com/features/ssl (`DATABASE_SSL`, as a stringified json object) - _ssl_ - an object describing ssl options, see https://node-postgres.com/features/ssl (`DATABASE_SSL`, as a stringified json object)
- _version_ - the postgres database version. Used to connect a non-standard database. Defaults to `undefined`, which let the underlying adapter to detect the version automatically. (`DATABASE_VERSION`)
- **databaseUrl** - the postgres database url to connect to. Only used if _db_ object is not specified. Should include username/password. This value may also be set via the `DATABASE_URL` environment variable. Alternatively, if you would like to read the database url from a file, you may set the `DATABASE_URL_FILE` environment variable with the full file path. The contents of the file must be the database url exactly. - **databaseUrl** - the postgres database url to connect to. Only used if _db_ object is not specified. Should include username/password. This value may also be set via the `DATABASE_URL` environment variable. Alternatively, if you would like to read the database url from a file, you may set the `DATABASE_URL_FILE` environment variable with the full file path. The contents of the file must be the database url exactly.
- **databaseSchema** - the postgres database schema to use. Defaults to 'public'. - **databaseSchema** - the postgres database schema to use. Defaults to 'public'.
- **port** - which port the unleash-server should bind to. If port is omitted or is 0, the operating system will assign an arbitrary unused port. Will be ignored if pipe is specified. This value may also be set via the `HTTP_PORT` environment variable - **port** - which port the unleash-server should bind to. If port is omitted or is 0, the operating system will assign an arbitrary unused port. Will be ignored if pipe is specified. This value may also be set via the `HTTP_PORT` environment variable

View File

@ -12,6 +12,7 @@ module.exports.createDb = function({
const logger = getLogger('db-pool.js'); const logger = getLogger('db-pool.js');
return knex({ return knex({
client: 'pg', client: 'pg',
version: db.version,
connection: db, connection: db,
pool: { min: poolMin, max: poolMax }, pool: { min: poolMin, max: poolMax },
searchPath: databaseSchema, searchPath: databaseSchema,

View File

@ -34,6 +34,7 @@ function defaultOptions() {
? JSON.parse(process.env.DATABASE_SSL) ? JSON.parse(process.env.DATABASE_SSL)
: false, : false,
driver: 'postgres', driver: 'postgres',
version: process.env.DATABASE_VERSION,
}, },
port: process.env.HTTP_PORT || process.env.PORT || 4242, port: process.env.HTTP_PORT || process.env.PORT || 4242,
host: process.env.HTTP_HOST, host: process.env.HTTP_HOST,

View File

@ -135,6 +135,7 @@ test('should prefer custom db connection options', t => {
database: 'db_database', database: 'db_database',
ssl: false, ssl: false,
driver: 'postgres', driver: 'postgres',
version: '10',
}; };
const options = createOptions({ databaseUrl, db }); const options = createOptions({ databaseUrl, db });