Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run CLI without mysql client #18

Closed
robmaceachern opened this issue Jul 11, 2014 · 16 comments
Closed

Can't run CLI without mysql client #18

robmaceachern opened this issue Jul 11, 2014 · 16 comments

Comments

@robmaceachern
Copy link

If I attempt to use the CLI without the mysql client dependency, it fails:

robmaceachern$ node_modules/.bin/sequelize db:migrate

/Users/robmaceachern/workspace/work/caravan/node_modules/sequelize/lib/sequelize.js:163
      throw new Error('The dialect ' + this.getDialect() + ' is not supported.
            ^
Error: The dialect mysql is not supported. (Error: Please install mysql package manually)
    at new module.exports.Sequelize (/Users/robmaceachern/workspace/work/caravan/node_modules/sequelize/lib/sequelize.js:163:13)
    at Object.<anonymous> (/Users/robmaceachern/workspace/work/caravan/node_modules/sequelize-cli/lib/helpers/migration-helper.js:5:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /Users/robmaceachern/workspace/work/caravan/node_modules/sequelize-cli/lib/helpers/index.js:12:54
    at Array.forEach (native)

The problem seems to be that migration-helper.js instantiates a Sequelize instance which is uses the mysql dialect as a default. It look it's just using the instance to map model names to table names.

Workaround: Adding "mysql": "^2.3.2", to my project package.json allows the CLI to run properly.

@d11wtq
Copy link

d11wtq commented Aug 3, 2014

I'm hitting this too and can't (read, don't want to) install mysql. There used to be an option for --config so you could provide it with the path to the sequelize config, but that seems to be have gone sequelize-cli.

@sdepold
Copy link
Member

sdepold commented Aug 3, 2014

will try to fix that during the next week! PRs are welcome though

@d11wtq
Copy link

d11wtq commented Aug 3, 2014

I fixed it locally by doing this:

var helpers   = require(__dirname)
  , _         = require('lodash')
  , _s        = require('underscore.string')
  , Sequelize = require('sequelize')
  , config    = helpers.config.readConfig()

var sequelize = new Sequelize(
  config.database,
  config.username,
  config.password,
  config
)

However, I don't think that will work with connection URLs?

@janmeier
Copy link
Member

janmeier commented Aug 3, 2014

You should be able to pass a connection URL to the constructor (new Sequelize(uri, options))

@d11wtq
Copy link

d11wtq commented Aug 3, 2014

Yeah, but I don't want to have to figure out which variant came from the config. I happen to be using a .js file that returns a JSON object, but AFAIK other users may be using connection URLs. I'm just reading config-helper.js now to understand it better. That code is at the top of migration-helper.js, where the bug is, BTW.

@d11wtq
Copy link

d11wtq commented Aug 3, 2014

Ah no, that code should actually fix this. The config-helper parses the URL and canonicalizes to JSON. I'll send a PR.

@d11wtq
Copy link

d11wtq commented Aug 3, 2014

I think it does seem like a clumsy way of converting names though, but it's pragmatic for now in any case.

@d11wtq
Copy link

d11wtq commented Aug 3, 2014

Raised #21. Would be nice to get a release out when it's possible. Or is there some way I can use my fork in the interim, without npm install clobbering it?

@janmeier
Copy link
Member

janmeier commented Aug 3, 2014

You can point your package.json at GH:

{
  "sequelize": "sequelize/sequelize#commit-ish"
}

@sdepold
Copy link
Member

sdepold commented Aug 6, 2014

their is a fair chance that this issue is fixed with #22.

@sdepold
Copy link
Member

sdepold commented Aug 6, 2014

i just released v0.2.4. can you give that a try?

@d11wtq
Copy link

d11wtq commented Aug 6, 2014

Tested, works. Thanks heaps! 👯

@sdepold
Copy link
Member

sdepold commented Aug 6, 2014

great!

@sdepold sdepold closed this as completed Aug 6, 2014
@aldricnbcu
Copy link

Don't wanna be a party pooper but this just happened for me.
I'll report back with more info on why this happened for me. Running Sequelize-CLI 2.0.0 ...

@aldricnbcu
Copy link

I should mention I'm trying to use postgres, and the relevant part of my config.json is

    "development": {
        "host": "localhost",
        "port": 3002,
        "cookieSecret": "cookieSecret",
        "sessionSecret": "sessionSecret",
        "database": {
            "username": "username",
            "password": "",
            "database": "database",
            "host":"localhost",
            "port": "5432",
            "dialect": "postgres"
        },
→ ./node_modules/.bin/sequelize db:migrate

Sequelize [Node: 4.1.1, CLI: 2.0.0, ORM: 3.11.0]

Loaded configuration file "config/config.json".
Using environment "development".
Using gulpfile ~/src/projects/chronos_web/node_modules/sequelize-cli/lib/gulpfile.js
Starting 'db:migrate'...
[Error: The dialect mysql is not supported. (Error: Please install mysql package manually)]
'db:migrate' errored after 26 msError: The dialect mysql is not supported. (Error: Please install mysql package manually)
    at new Sequelize (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize/lib/sequelize.js:203:11)
    at getSequelizeInstance (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/lib/tasks/db.js:284:12)
    at getMigrator (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/lib/tasks/db.js:293:21)
    at Object.module.exports.db:migrate.task (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/lib/tasks/db.js:23:7)
    at Gulp.gulp.task.aliases (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/lib/helpers/gulp-helper.js:14:14)
    at module.exports (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /Users/a206468627/src/projects/chronos_web/node_modules/sequelize-cli/node_modules/gulp/bin/gulp.js:129:20
    at doNTCallback0 (node.js:407:9)
    at process._tickCallback (node.js:336:13)
    at Function.Module.runMain (module.js:477:11)
    at startup (node.js:117:18)
    at node.js:951:3

@aldricnbcu
Copy link

Haha, never mind, this is actually just a horribly unclear error message because the sequelize-cli code defaults to mysql instead of telling you what actually went wrong, to wit, it couldn't find an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants