Skip to content

Commit 74c1da4

Browse files
committed
Simplify output with sequelize database argument
1 parent 50b72c7 commit 74c1da4

2 files changed

Lines changed: 10 additions & 31 deletions

File tree

bin/heroku

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,13 @@ module.exports = {
1818
}
1919
2020
EOF
21-
regex='postgres:\/\/([^:]+):([^@]+)@([^:]+):([^\/]+)\/(.+)'
2221

23-
if [[ $DATABASE_URL =~ $regex ]]; then
24-
25-
username="${BASH_REMATCH[1]}"
26-
password="${BASH_REMATCH[2]}"
27-
host="${BASH_REMATCH[3]}"
28-
port="${BASH_REMATCH[4]}"
29-
database="${BASH_REMATCH[5]}"
30-
31-
cat << EOF > config.json
22+
cat << EOF > config.json
3223
3324
{
3425
"production": {
3526
"db": {
36-
"dialect": "postgres",
37-
"host": "${host}",
38-
"username": "${username}",
39-
"password": "${password}",
40-
"database": "${database}",
41-
"port": "${port}",
27+
"database": "${DATABASE_URL}",
4228
"dialectOptions": {
4329
"ssl": true
4430
}
@@ -47,19 +33,6 @@ EOF
4733
}
4834
4935
EOF
50-
else
51-
52-
cat << EOF > config.json
53-
54-
{
55-
"production": {
56-
}
57-
}
58-
59-
EOF
60-
61-
fi
62-
6336

6437
cp public/js/config.js.example public/js/config.js
6538

lib/models/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ var logger = require("../logger.js");
1111

1212
var dbconfig = config.db;
1313
dbconfig.logging = config.debug ? logger.info : false;
14-
var sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig);
14+
15+
var sequelize;
16+
if (typeof dbconfig.username === 'undefined' && typeof dbconfig.password === 'undefined') {
17+
sequelize = new Sequelize(dbconfig.database, dbconfig);
18+
} else {
19+
sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig);
20+
}
1521

1622
var db = {};
1723

@@ -34,4 +40,4 @@ Object.keys(db).forEach(function (modelName) {
3440
db.sequelize = sequelize;
3541
db.Sequelize = Sequelize;
3642

37-
module.exports = db;
43+
module.exports = db;

0 commit comments

Comments
 (0)