Simplify output with sequelize database argument
This commit is contained in:
parent
50b72c7f03
commit
74c1da4536
2 changed files with 10 additions and 31 deletions
31
bin/heroku
31
bin/heroku
|
@ -18,27 +18,13 @@ module.exports = {
|
|||
}
|
||||
|
||||
EOF
|
||||
regex='postgres:\/\/([^:]+):([^@]+)@([^:]+):([^\/]+)\/(.+)'
|
||||
|
||||
if [[ $DATABASE_URL =~ $regex ]]; then
|
||||
|
||||
username="${BASH_REMATCH[1]}"
|
||||
password="${BASH_REMATCH[2]}"
|
||||
host="${BASH_REMATCH[3]}"
|
||||
port="${BASH_REMATCH[4]}"
|
||||
database="${BASH_REMATCH[5]}"
|
||||
|
||||
cat << EOF > config.json
|
||||
cat << EOF > config.json
|
||||
|
||||
{
|
||||
"production": {
|
||||
"db": {
|
||||
"dialect": "postgres",
|
||||
"host": "${host}",
|
||||
"username": "${username}",
|
||||
"password": "${password}",
|
||||
"database": "${database}",
|
||||
"port": "${port}",
|
||||
"database": "${DATABASE_URL}",
|
||||
"dialectOptions": {
|
||||
"ssl": true
|
||||
}
|
||||
|
@ -47,19 +33,6 @@ EOF
|
|||
}
|
||||
|
||||
EOF
|
||||
else
|
||||
|
||||
cat << EOF > config.json
|
||||
|
||||
{
|
||||
"production": {
|
||||
}
|
||||
}
|
||||
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
|
||||
cp public/js/config.js.example public/js/config.js
|
||||
|
||||
|
|
|
@ -11,7 +11,13 @@ 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;
|
||||
if (typeof dbconfig.username === 'undefined' && typeof dbconfig.password === 'undefined') {
|
||||
sequelize = new Sequelize(dbconfig.database, dbconfig);
|
||||
} else {
|
||||
sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig);
|
||||
}
|
||||
|
||||
var db = {};
|
||||
|
||||
|
@ -34,4 +40,4 @@ Object.keys(db).forEach(function (modelName) {
|
|||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
|
||||
module.exports = db;
|
||||
module.exports = db;
|
||||
|
|
Loading…
Reference in a new issue