Cli: Config via environment variables?

Created on 2 Feb 2015  路  4Comments  路  Source: sequelize/cli

It seems, the only way to set db connection parameters is to specify config.json file. But, in some cases you don't need to handle environment in app yourself. So, I'm interested is there any way to set connection parameters explicitly via environment variables. Something like that:

.sequelizerc:

var path = require('path')
module.exports = {
  'config': {
    host: process.env.DB0_HOST,
    port: process.env.DB0_PORT,
    database: process.env.DB0_NAME,
    username: process.env.DB0_USERNAME,
    password: process.env.DB0_PASSWORD,
    dialect: "postgres"
  },
  'migrations-path': path.resolve('coffee/server', 'migrations'),
  'models-path': path.resolve('coffee/server', 'models'),
  'coffee': true
}

Thanks :)

Most helpful comment

A bit late, but exactly what I needed! xD Thanks.

BTW, it may be useful to mention this approach in docs.

All 4 comments

May I point you to this comment? https://github.com/sequelize/cli/issues/77#issuecomment-68299495
Please let me know if this works for you and I will add it to the readme.

Closing this for now. Please re-open if it is still an issue

A bit late, but exactly what I needed! xD Thanks.

BTW, it may be useful to mention this approach in docs.

I'd leave ^ as a thumbs-up, but I believe it might be valuable for the maintainers to know that I came to here after thinking of the same question while reading http://docs.sequelizejs.com/manual/tutorial/migrations.html.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

axetroy picture axetroy  路  3Comments

przbadu picture przbadu  路  3Comments

PavelPolyakov picture PavelPolyakov  路  6Comments

TangMonk picture TangMonk  路  3Comments

LucasBadico picture LucasBadico  路  5Comments