json - sequalize migration with dotenv -
i saving database config in dotenv file.
i using sequelize migration has config.json file in config folder:
{ "development": { "username": "root", "password": null, "database": "test", "host": "127.0.0.1", "dialect": "postgres" }, .... }
since have configuration in dotenv have convert 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 run the migration, config not json?
node_modules/.bin/sequelize db:migrate --config config/config.js
if you're using version 2.0 or later config/config.js
1 of defaults, shouldn't concern.
you can create .sequelizerc
file can override path and/or name if you'd prefer. it's in the documentation under "options".
Comments
Post a Comment