4.1.10: Deploy Sequelize App to Heroku


Deploying the base MVC (and Webpack) app is the same as deploying previous apps to Heroku with one difference- the database.
When using Sequelize we need to have different configs for connecting to the Heroku Postgres instance. Those configs are here:​
// ...
production: {
use_env_variable: 'DATABASE_URL',
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {
ssl: { //
require: true,
rejectUnauthorized: false,
// ...
if (env === 'production') {
// Break apart the Heroku database url and rebuild the configs we need
const { DATABASE_URL } = process.env;
const dbUrl = url.parse(DATABASE_URL);
const username = dbUrl.auth.substr(0, dbUrl.auth.indexOf(':'));
const password = dbUrl.auth.substr(
dbUrl.auth.indexOf(':') + 1,
const dbName = dbUrl.path.slice(1);
const host = dbUrl.hostname;
const { port } = dbUrl; = host;
config.port = port;
sequelize = new Sequelize(dbName, username, password, config);
These are all included configs that don't need to be changed.

Initializing the DB

To get your Sequelize database running on Heroku, run the Sequelize commands within the Heroku system. (No need to create the database, that's already been done when you provision the Postgres add-on.)
heroku run npx sequelize-cli db:migrate
heroku run npx sequelize-cli db:seed:all