postgresql - I'm using the Node.js ORM Sequelize and its command line client and I'm having difficulty successfully executing migrations -


in app i'm using sequelize-cli set tables , run migrations postgresql database. here's code:

.sequelizerc

var path = require("path");  module.exports = {   'config': path.resolve('config', 'database.json'),   'migrations-path': path.resolve('db', 'migrate') } 

config/database.json

{ "development": {     "username": "sol",     "password": null,     "database": "experiments",     "host": "127.0.0.1",     "dialect": "postgres"     }, "production": {     "username": "sol",     "password": null,     "database": "experiments",     "host": "127.0.0.1",     "dialect": "postgres"     }  } 

i created 2 models in models directory , created migration file using sequelize migration:create in db/migrate directory. run sequelize db:migrate run migration, when check postgresql database there no new tables created. response after running command:

loaded configuration file "config/database.json". using environment "development".     @ new module.exports.sequelize (/users/sol/src/projects/tests/node.js/tovisit/node_modules/sequelize/lib/sequelize.js:182:13)     @ getsequelizeinstance (/usr/local/lib/node_modules/sequelize-cli/lib/tasks/db.js:203:10)     @ getmigrator (/usr/local/lib/node_modules/sequelize-cli/lib/tasks/db.js:208:21)     @ object.module.exports.db:migrate.task (/usr/local/lib/node_modules/sequelize-cli/lib/tasks/db.js:23:7)     @ gulp.gulp.task.aliases (/usr/local/lib/node_modules/sequelize-cli/lib/helpers/gulp-helper.js:14:14)     @ module.exports (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/lib/runtask.js:34:7)     @ gulp.orchestrator._runtask (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:273:3)     @ gulp.orchestrator._runstep (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:214:10)     @ gulp.orchestrator.start (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:134:8)     @ /usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/bin/gulp.js:129:20     @ process._tickcallback (node.js:419:13)     @ function.module.runmain (module.js:499:11)     @ startup (node.js:119:16)     @ node.js:906:3 

as turns out problem sequelize-cli unable locate postgresql on account didn't have necessary modules pg , pg-hstore installed. discovered while programmatically using sequelize through server. threw me error portion of can seen here:

throw new error('the dialect ' + this.getdialect() + ' not supported.         ^ error: dialect postgres not supported. (error: cannot find module 'pg-hstore') 

from there simple google search led me little more detailed explanation , able run migrations successfully!


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -