Skip to content

Commit 50b72c7

Browse files
committed
Fix heroku production db setting
1 parent 9769b0c commit 50b72c7

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

bin/heroku

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,38 @@ module.exports = {
1818
}
1919
2020
EOF
21+
regex='postgres:\/\/([^:]+):([^@]+)@([^:]+):([^\/]+)\/(.+)'
2122

22-
cat << EOF > config.json
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
32+
33+
{
34+
"production": {
35+
"db": {
36+
"dialect": "postgres",
37+
"host": "${host}",
38+
"username": "${username}",
39+
"password": "${password}",
40+
"database": "${database}",
41+
"port": "${port}",
42+
"dialectOptions": {
43+
"ssl": true
44+
}
45+
}
46+
}
47+
}
48+
49+
EOF
50+
else
51+
52+
cat << EOF > config.json
2353
2454
{
2555
"production": {
@@ -28,6 +58,9 @@ EOF
2858
2959
EOF
3060

61+
fi
62+
63+
3164
cp public/js/config.js.example public/js/config.js
3265

3366
# build app

0 commit comments

Comments
 (0)