Created
January 23, 2013 13:38
-
-
Save alduro/4605672 to your computer and use it in GitHub Desktop.
Sequelize Locomotive initializer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function() { | |
console.log('ENVIRONMENT'); | |
console.log(this.env); | |
switch(this.env) { | |
case 'development': | |
var sequelize = new Sequelize('paragon_development', 'root', null); | |
break; | |
case 'production': | |
if (process.env['HEROKU_POSTGRESQL_COPPER_URL']) { | |
var url = require('url').parse(process.env['HEROKU_POSTGRESQL_COPPER_URL']); | |
console.log(url); | |
var pgOpts = { | |
pathname: url.pathname, | |
port: url.port, | |
host: url.hostname, | |
user: url.auth.split(':')[0], | |
pass: url.auth.split(':')[1] | |
}; | |
var sequelize = new Sequelize(pgOpts.pathname, pgOpts.user , pgOpts.pass, { | |
host: pgOpts.hostname, | |
port: pgOpts.port, | |
dialect: 'postgres', | |
// custom protocol | |
// - default: 'tcp' | |
// - added in: v1.5.0 | |
// - postgres only, useful for heroku | |
protocol: null | |
}); | |
} | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Heroku var:
HEROKU_POSTGRESQL_JADE_URL: postgres://sgcggjfwldxmvj:PeLXfyFqOBomqjny8bGRcMiNGn@ec2-54-243-181-115.compute-1.amazonaws.com:5432/ddr742teg2dnho