I am saving my database config in dotenv file.
I am using sequelize migration which has a config.json file in config folder:
{
"development": {
"username": "root",
"password": null,
"database": "test",
"host": "127.0.0.1",
"dialect": "postgres"
},
....
}
Since I have configuration in dotenv do I have to convert it to js file:
require('dotenv').config({ silent: env === 'production'})
const devConfig = {
dialect: 'postgres',
host: process.env.DB_HOST || 'localhost',
port: process.env.DB_PORT || 5432,
database: process.env.DB_NAME || '',
username: process.env.DB_USER || 'postgres',
password: process.env.DB_PASSWORD || '',
migrationStorageTableName: 'migrations'
};
module.exports = {
development: devConfig,
production: devConfig
};
but how can I run the the migration, which the config is not JSON?
node_modules/.bin/sequelize db:migrate --config config/config.js
npx sequelize-cli --help
– Daves