summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Wu2016-12-12 13:22:04 +0800
committerGitHub2016-12-12 13:22:04 +0800
commit159be6a7c775651cf2f9d4625d3a64ddd1991f32 (patch)
tree7c9a4c17cc1a71ca4ad1888814d52c767439cc8f
parentbb3ed8e249ebf8b8c6801cb81610f127db40b580 (diff)
parent5282bf491e299e50f65484d987558e7bfc031c4b (diff)
Merge pull request #277 from hackmdio/heroku-sequelize
Fix heroku production postgres setting
-rwxr-xr-xbin/heroku8
-rw-r--r--lib/models/index.js9
2 files changed, 14 insertions, 3 deletions
diff --git a/bin/heroku b/bin/heroku
index f30b2b23..0375e9e7 100755
--- a/bin/heroku
+++ b/bin/heroku
@@ -19,10 +19,16 @@ module.exports = {
EOF
- cat << EOF > config.json
+ cat << EOF > config.json
{
"production": {
+ "db": {
+ "database": "${DATABASE_URL}",
+ "dialectOptions": {
+ "ssl": true
+ }
+ }
}
}
diff --git a/lib/models/index.js b/lib/models/index.js
index 3b49d459..d52f5508 100644
--- a/lib/models/index.js
+++ b/lib/models/index.js
@@ -11,7 +11,12 @@ var logger = require("../logger.js");
var dbconfig = config.db;
dbconfig.logging = config.debug ? logger.info : false;
-var sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig);
+
+var sequelize = null;
+if (dbconfig.hasOwnProperty('username') || dbconfig.hasOwnProperty('password'))
+ sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig);
+else
+ sequelize = new Sequelize(dbconfig.database, dbconfig);
var db = {};
@@ -34,4 +39,4 @@ Object.keys(db).forEach(function (modelName) {
db.sequelize = sequelize;
db.Sequelize = Sequelize;
-module.exports = db; \ No newline at end of file
+module.exports = db;