I'm using Sequelize as an ORM and I'm trying to migrate my database to Heroku. When running heroku run sequelize db:migrate
I just get
Loaded configuration file "config/config.js".
Using environment "production".
ERROR: Error parsing url: undefined
Here's what my config file looks like:
module.exports = {
"development": {
"username": "root",
"password": "password",
"database": "vueapp",
"host": "127.0.0.1",
"dialect": "postgres"
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "mysql"
},
"production": {
"use_env_variable": process.env.DATABASE_URL,
"dialect": "postgres",
"ssl": true,
"dialectOptions": {
"ssl": true
}
}
}
And the index file
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config')[env];
const User = require("./user")
const Hour = require('./hours');
const db = {
User,
Hour
};
let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(config.use_env_variable, config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(file => {
const model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});
Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
Not entirely sure what the issue is. Going through the heroku logs, I see a throw new Error('Dialect needs to be explicitly supplied as of v4.0.0');
But I have added the dialect in the config.js file. Does it matter if the config file is a .js file or a .json file?
Just to clarify, the actual web app opens up and I can see the error handler that I set up. So I'm not actually getting an application error when opening up the route URL