KSDaemon/sails-hook-sequelize

Sequelize CLI support

mrded opened this issue · 1 comments

mrded commented

I'm trying to use Sequelize CLI with sails, and then I run sequelize db:drop - it gives me an error:

Sequelize CLI [Node: 8.7.0, CLI: 3.0.0, ORM: 4.13.6]

WARNING: This version of Sequelize CLI is not fully compatible with Sequelize v4. https://github.com/sequelize/cli#sequelize-support

Loaded configuration file "config/sequelize.js".

ERROR: Dialect undefined does not support db:create / db:drop commands

It happens because it doesn't understand that my database settings are defended in config/datastores.js and config/env/*.js files, under sails.config.connections || sails.config.datastores variables.

Sails itself does understand it, thanks to sails-hook-sequelize, but sequelize-cli doesn't.

I can solve that problem with following hack in config/sequelize.js:

var path = require('path');

var config = require(path.resolve('config/env', process.env.NODE_ENV || 'development')); 

var datastore = config.datastores.default;

module.exports = Object.assign(datastore, { charset: 'utf8' }); 

However I believe, it would be nice if sails-hook-sequelize supports sequelize-cli as well.

@mrded Can you give me a full snapshot of how you did this? Thanks!