using an enviroment variable for local sequelize configuration

I worked on this for quite a bit. I do not know why Sequelize does not use production when it is literally in the environment if you run heroku run bash. I was able to get it working by modifying the Sequelize object depending on the JAWSDB_URL, not the NODE_ENV.

require("dotenv").config();
const express = require("express")
const app = express();
let seq;

//express app configuration

if (process.env.JAWSDB_URL) {
    console.log("There is a JAWS DB URL")
    seq = new Sequelize(process.env.JAWSDB_URL)
}
else {
    seq = require("./models").sequelize
}
seq.sync().then(() => {
  app.listen(PORT, () => console.log('server started on port ' + PORT));
})

you should change config.json file to a config.js module and make sure to require the dotenv at the very top.

require('dotenv').config(); // this is important!
module.exports = {
"development": {
    "username": process.env.DB_USERNAME,
    "password": process.env.DB_PASSWORD,
    "database": process.env.DB_DATABASE,
    "host": process.env.DB_HOST,
    "dialect": "mysql"
},
"test": {
    "username": "root",
    "password": null,
    "database": "database_test",
    "host": "127.0.0.1",
    "dialect": "mysql"
},
"production": {
    "username": "root",
    "password": null,
    "database": "database_production",
    "host": "127.0.0.1",
    "dialect": "mysql"
}
};

NOTE: update your .sequelizerc file to match the new config file.

"config": path.resolve('./config', 'config.js'),