Sequelize Configuration Reading Wrong Dialect
I am working on updating my sequezlie config file so that it runs off env variables when the cli migration command is run. My setup works fine for remote servers that enable the env variables stored, but my local environment (like all) does not unless dotenv
is run. I configured dotenv
in my config file only if the environment recognized is development
and my console log is outputting the correct process.env.DB_DIALECT
of postgres
, but for some reason, during the migration, sequelize is telling me to download mysql
. Can anyone help with this bizarre issue?
Here is the head of my terminal output and error message:
DEVELOPMENT DOTENV
postgres
Loaded configuration file "config/config.js".
Error: Please install mysql package manually
at new ConnectionManager (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:23:11)
at new MysqlDialect (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/index.js:12:28)
at new Sequelize (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/sequelize.js:220:18)
Here is my config file:
var express = require('express');
var app = express();
var path = require('path');
if(app.get('env') === 'development'){
console.log('DEVELOPMENT DOTENV')
require('dotenv').config();
};
console.log(process.env.DB_DIALECT) //postgres
module.exports = {
"development": {
"username": process.env.DB_LOCAL_USERNAME,
"password": process.env.DB_LOCAL_PASSWORD,
"database": process.env.DB_LOCAL_DATABASE,
"host": "127.0.0.1",
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta",
"autoMigrateOldSchema": true
},
"staging": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
},
"production": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
}
}
Here is my migration file:
'use strict';
module.exports = {
up: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization ADD CONSTRAINT organization_user_id_fkey FOREIGN KEY (admin_id) REFERENCES synotate_user (user_id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;");
},
down: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization DROP CONSTRAINT organization_user_id_fkey;");
}
};
sequelize.js sequelize-cli
add a comment |
I am working on updating my sequezlie config file so that it runs off env variables when the cli migration command is run. My setup works fine for remote servers that enable the env variables stored, but my local environment (like all) does not unless dotenv
is run. I configured dotenv
in my config file only if the environment recognized is development
and my console log is outputting the correct process.env.DB_DIALECT
of postgres
, but for some reason, during the migration, sequelize is telling me to download mysql
. Can anyone help with this bizarre issue?
Here is the head of my terminal output and error message:
DEVELOPMENT DOTENV
postgres
Loaded configuration file "config/config.js".
Error: Please install mysql package manually
at new ConnectionManager (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:23:11)
at new MysqlDialect (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/index.js:12:28)
at new Sequelize (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/sequelize.js:220:18)
Here is my config file:
var express = require('express');
var app = express();
var path = require('path');
if(app.get('env') === 'development'){
console.log('DEVELOPMENT DOTENV')
require('dotenv').config();
};
console.log(process.env.DB_DIALECT) //postgres
module.exports = {
"development": {
"username": process.env.DB_LOCAL_USERNAME,
"password": process.env.DB_LOCAL_PASSWORD,
"database": process.env.DB_LOCAL_DATABASE,
"host": "127.0.0.1",
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta",
"autoMigrateOldSchema": true
},
"staging": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
},
"production": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
}
}
Here is my migration file:
'use strict';
module.exports = {
up: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization ADD CONSTRAINT organization_user_id_fkey FOREIGN KEY (admin_id) REFERENCES synotate_user (user_id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;");
},
down: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization DROP CONSTRAINT organization_user_id_fkey;");
}
};
sequelize.js sequelize-cli
My guess: Sequelize CLI does not know about your custom config path and is defaulting to mysql. Try creating a file.sequelizerc
in your root with the following:module.exports = {'config': './config/config.js'};
– mcranston18
Nov 16 '18 at 13:43
That unfortunately did not change the outcome.var path = require('path'); module.exports = { 'models-path': path.resolve('./app/', 'models'), 'config': './config/config.js' }
outputsLoaded configuration file "config/config.js". Error: Please install mysql package manually
– cphill
Nov 18 '18 at 16:21
Hm. This is strange. I still suspect your env config is not being picked up properly by the Sequelize CLI. When you console.logprocess.env.NODE_ENV
, what does it say? It must saydevelopment
,staging
, orproduction
as those are the keys you have defined
– mcranston18
Nov 18 '18 at 16:45
add a comment |
I am working on updating my sequezlie config file so that it runs off env variables when the cli migration command is run. My setup works fine for remote servers that enable the env variables stored, but my local environment (like all) does not unless dotenv
is run. I configured dotenv
in my config file only if the environment recognized is development
and my console log is outputting the correct process.env.DB_DIALECT
of postgres
, but for some reason, during the migration, sequelize is telling me to download mysql
. Can anyone help with this bizarre issue?
Here is the head of my terminal output and error message:
DEVELOPMENT DOTENV
postgres
Loaded configuration file "config/config.js".
Error: Please install mysql package manually
at new ConnectionManager (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:23:11)
at new MysqlDialect (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/index.js:12:28)
at new Sequelize (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/sequelize.js:220:18)
Here is my config file:
var express = require('express');
var app = express();
var path = require('path');
if(app.get('env') === 'development'){
console.log('DEVELOPMENT DOTENV')
require('dotenv').config();
};
console.log(process.env.DB_DIALECT) //postgres
module.exports = {
"development": {
"username": process.env.DB_LOCAL_USERNAME,
"password": process.env.DB_LOCAL_PASSWORD,
"database": process.env.DB_LOCAL_DATABASE,
"host": "127.0.0.1",
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta",
"autoMigrateOldSchema": true
},
"staging": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
},
"production": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
}
}
Here is my migration file:
'use strict';
module.exports = {
up: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization ADD CONSTRAINT organization_user_id_fkey FOREIGN KEY (admin_id) REFERENCES synotate_user (user_id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;");
},
down: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization DROP CONSTRAINT organization_user_id_fkey;");
}
};
sequelize.js sequelize-cli
I am working on updating my sequezlie config file so that it runs off env variables when the cli migration command is run. My setup works fine for remote servers that enable the env variables stored, but my local environment (like all) does not unless dotenv
is run. I configured dotenv
in my config file only if the environment recognized is development
and my console log is outputting the correct process.env.DB_DIALECT
of postgres
, but for some reason, during the migration, sequelize is telling me to download mysql
. Can anyone help with this bizarre issue?
Here is the head of my terminal output and error message:
DEVELOPMENT DOTENV
postgres
Loaded configuration file "config/config.js".
Error: Please install mysql package manually
at new ConnectionManager (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:23:11)
at new MysqlDialect (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/dialects/mysql/index.js:12:28)
at new Sequelize (/Users/user/Desktop/Projects/node/app/node_modules/sequelize/lib/sequelize.js:220:18)
Here is my config file:
var express = require('express');
var app = express();
var path = require('path');
if(app.get('env') === 'development'){
console.log('DEVELOPMENT DOTENV')
require('dotenv').config();
};
console.log(process.env.DB_DIALECT) //postgres
module.exports = {
"development": {
"username": process.env.DB_LOCAL_USERNAME,
"password": process.env.DB_LOCAL_PASSWORD,
"database": process.env.DB_LOCAL_DATABASE,
"host": "127.0.0.1",
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta",
"autoMigrateOldSchema": true
},
"staging": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
},
"production": {
"username": process.env.RDS_USERNAME,
"password": process.env.RDS_PASSWORD,
"database": process.env.RDS_DATABASE,
"host": process.env.RDS_HOSTNAME,
"dialect": process.env.DB_DIALECT,
"migrationStorageTableName": "sequelize_meta"
}
}
Here is my migration file:
'use strict';
module.exports = {
up: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization ADD CONSTRAINT organization_user_id_fkey FOREIGN KEY (admin_id) REFERENCES synotate_user (user_id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;");
},
down: function (queryInterface, Sequelize) {
queryInterface.sequelize.query("ALTER TABLE organization DROP CONSTRAINT organization_user_id_fkey;");
}
};
sequelize.js sequelize-cli
sequelize.js sequelize-cli
asked Nov 16 '18 at 11:59
cphillcphill
1,69963881
1,69963881
My guess: Sequelize CLI does not know about your custom config path and is defaulting to mysql. Try creating a file.sequelizerc
in your root with the following:module.exports = {'config': './config/config.js'};
– mcranston18
Nov 16 '18 at 13:43
That unfortunately did not change the outcome.var path = require('path'); module.exports = { 'models-path': path.resolve('./app/', 'models'), 'config': './config/config.js' }
outputsLoaded configuration file "config/config.js". Error: Please install mysql package manually
– cphill
Nov 18 '18 at 16:21
Hm. This is strange. I still suspect your env config is not being picked up properly by the Sequelize CLI. When you console.logprocess.env.NODE_ENV
, what does it say? It must saydevelopment
,staging
, orproduction
as those are the keys you have defined
– mcranston18
Nov 18 '18 at 16:45
add a comment |
My guess: Sequelize CLI does not know about your custom config path and is defaulting to mysql. Try creating a file.sequelizerc
in your root with the following:module.exports = {'config': './config/config.js'};
– mcranston18
Nov 16 '18 at 13:43
That unfortunately did not change the outcome.var path = require('path'); module.exports = { 'models-path': path.resolve('./app/', 'models'), 'config': './config/config.js' }
outputsLoaded configuration file "config/config.js". Error: Please install mysql package manually
– cphill
Nov 18 '18 at 16:21
Hm. This is strange. I still suspect your env config is not being picked up properly by the Sequelize CLI. When you console.logprocess.env.NODE_ENV
, what does it say? It must saydevelopment
,staging
, orproduction
as those are the keys you have defined
– mcranston18
Nov 18 '18 at 16:45
My guess: Sequelize CLI does not know about your custom config path and is defaulting to mysql. Try creating a file
.sequelizerc
in your root with the following: module.exports = {'config': './config/config.js'};
– mcranston18
Nov 16 '18 at 13:43
My guess: Sequelize CLI does not know about your custom config path and is defaulting to mysql. Try creating a file
.sequelizerc
in your root with the following: module.exports = {'config': './config/config.js'};
– mcranston18
Nov 16 '18 at 13:43
That unfortunately did not change the outcome.
var path = require('path'); module.exports = { 'models-path': path.resolve('./app/', 'models'), 'config': './config/config.js' }
outputs Loaded configuration file "config/config.js". Error: Please install mysql package manually
– cphill
Nov 18 '18 at 16:21
That unfortunately did not change the outcome.
var path = require('path'); module.exports = { 'models-path': path.resolve('./app/', 'models'), 'config': './config/config.js' }
outputs Loaded configuration file "config/config.js". Error: Please install mysql package manually
– cphill
Nov 18 '18 at 16:21
Hm. This is strange. I still suspect your env config is not being picked up properly by the Sequelize CLI. When you console.log
process.env.NODE_ENV
, what does it say? It must say development
, staging
, or production
as those are the keys you have defined– mcranston18
Nov 18 '18 at 16:45
Hm. This is strange. I still suspect your env config is not being picked up properly by the Sequelize CLI. When you console.log
process.env.NODE_ENV
, what does it say? It must say development
, staging
, or production
as those are the keys you have defined– mcranston18
Nov 18 '18 at 16:45
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337479%2fsequelize-configuration-reading-wrong-dialect%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337479%2fsequelize-configuration-reading-wrong-dialect%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
My guess: Sequelize CLI does not know about your custom config path and is defaulting to mysql. Try creating a file
.sequelizerc
in your root with the following:module.exports = {'config': './config/config.js'};
– mcranston18
Nov 16 '18 at 13:43
That unfortunately did not change the outcome.
var path = require('path'); module.exports = { 'models-path': path.resolve('./app/', 'models'), 'config': './config/config.js' }
outputsLoaded configuration file "config/config.js". Error: Please install mysql package manually
– cphill
Nov 18 '18 at 16:21
Hm. This is strange. I still suspect your env config is not being picked up properly by the Sequelize CLI. When you console.log
process.env.NODE_ENV
, what does it say? It must saydevelopment
,staging
, orproduction
as those are the keys you have defined– mcranston18
Nov 18 '18 at 16:45