I have been working on a NodeJS project which uses PostgreSQL database. I am trying to implement migration to the database. Also, using Sequelize. After setting up the migration folder and config, it throws error while running db:migrate
The error is: "Dialect needs to be explicitly supplied as of v4.0.0"
Sequelize is independent from specific dialects. This means that you'll have to install the respective connector library to your project yourself.
Sequelize is a Node. js-based Object Relational Mapper that makes it easy to work with MySQL, MariaDB, SQLite, PostgreSQL databases, and more. An Object Relational Mapper performs functions like handling database records by representing the data as objects.
Solution for me was based on what I had set for my NODE_ENV
variable.
echo $NODE_ENV
If you do not have anything set for that variable, try setting it with the following:
export NODE_ENV=development
If a value is present, make sure you have an entry in your config file for that value. For me, I like to use local
. So I had to update my config to this:
{ local: { username: 'root', password: null, database: 'database_dev', host: '127.0.0.1', dialect: 'postgres' }, development: { username: 'root', password: null, database: 'database_dev', host: '127.0.0.1', dialect: 'postgres' }, test: { username: 'root', password: null, database: 'database_test', host: '127.0.0.1', dialect: 'postgres' }, production: { username: 'root', password: null, database: 'database', host: '127.0.0.1', dialect: 'postgres' } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With