PostgreSQL database driver (#5861)

* [test/database/list] Fix test list 4 being used in two different tests

* [database/postgres] PostgreSQL database driver

* [database/postgres] Make transactions work based on continuation scope.

* [database/postgres] Implement nested transactions

* eslint --fix

* Add database changes from earlier this week to the PostgreSQL driver.

* Fix typo

* Fix postgres.incrObjectFieldBy returning undefined instead of null when given NaN

* [database/postgres] Fix sortedSetsCard returning an array of strings.

* Update socket.io postgres adapter

* Fix PostgreSQL erroring when multiple updates are made to the same sorted set entry in a single operation.

Add a test case to catch this error.

* Fix lint errors.

* Only prune sessions on one instance in a cluster to avoid deadlocks.

They're caught and handled by the database server, but they spam the logs.

* Fix arguments.slice.
This commit is contained in:
Ben Lubar
2018-08-08 14:13:48 -05:00
committed by Julian Lam
parent 3cccbbc1f2
commit 33228bb7fe
34 changed files with 3166 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ var winston = require('winston');
var questions = {
redis: require('../src/database/redis').questions,
mongo: require('../src/database/mongo').questions,
postgres: require('../src/database/postgres').questions,
};
module.exports = function (config, callback) {
@@ -38,6 +39,12 @@ function getDatabaseConfig(config, callback) {
} else {
prompt.get(questions.mongo, callback);
}
} else if (config.database === 'postgres') {
if (config['postgres:host'] && config['postgres:port']) {
callback(null, config);
} else {
prompt.get(questions.postgres, callback);
}
} else {
return callback(new Error('unknown database : ' + config.database));
}
@@ -69,11 +76,19 @@ function saveDatabaseConfig(config, databaseConfig, callback) {
database: databaseConfig['mongo:database'],
uri: databaseConfig['mongo:uri'],
};
} else if (config.database === 'postgres') {
config.postgres = {
host: databaseConfig['postgres:host'],
port: databaseConfig['postgres:port'],
username: databaseConfig['postgres:username'],
password: databaseConfig['postgres:password'],
database: databaseConfig['postgres:database'],
};
} else {
return callback(new Error('unknown database : ' + config.database));
}
var allQuestions = questions.redis.concat(questions.mongo);
var allQuestions = questions.redis.concat(questions.mongo).concat(questions.postgres);
for (var x = 0; x < allQuestions.length; x += 1) {
delete config[allQuestions[x].name];
}

View File

@@ -29,13 +29,15 @@
"cli-graph": "^3.2.2",
"clipboard": "^2.0.1",
"colors": "^1.1.2",
"compression": "^1.7.1",
"commander": "^2.12.2",
"compression": "^1.7.1",
"connect-ensure-login": "^0.1.1",
"connect-flash": "^0.1.1",
"connect-mongo": "2.0.1",
"connect-multiparty": "^2.1.0",
"connect-pg-simple": "^4.2.1",
"connect-redis": "3.3.3",
"continuation-local-storage": "^3.2.1",
"cookie-parser": "^1.4.3",
"cron": "^1.3.0",
"cropperjs": "^1.2.2",
@@ -82,6 +84,8 @@
"nodemailer": "^4.6.5",
"passport": "^0.4.0",
"passport-local": "1.0.0",
"pg": "^7.4.0",
"pg-cursor": "^1.3.0",
"postcss": "7.0.2",
"postcss-clean": "1.1.0",
"promise-polyfill": "^8.0.0",
@@ -97,6 +101,7 @@
"socket.io": "2.1.1",
"socket.io-adapter-cluster": "^1.0.1",
"socket.io-adapter-mongo": "^2.0.1",
"socket.io-adapter-postgres": "^1.0.1",
"socket.io-client": "2.1.1",
"socket.io-redis": "5.2.0",
"socketio-wildcard": "2.0.0",

View File

@@ -90,7 +90,7 @@ function ping(req, res) {
}
function welcome(req, res) {
var dbs = ['redis', 'mongo'];
var dbs = ['redis', 'mongo', 'postgres'];
var databases = dbs.map(function (databaseName) {
var questions = require('../src/database/' + databaseName).questions.filter(function (question) {
return question && !question.hideOnWebInstall;