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

Unable to resolve storage 'sequelize' [on Win7 64-bit] #73

Closed
jagged3dge opened this issue Dec 19, 2014 · 43 comments · Fixed by #74
Closed

Unable to resolve storage 'sequelize' [on Win7 64-bit] #73

jagged3dge opened this issue Dec 19, 2014 · 43 comments · Fixed by #74

Comments

@jagged3dge
Copy link

Hi,

I am using sequelize-cli to migrate new changes to my running solution. Basically, creating a workflow for pushing updates to my MySQL server hosting my test db. I have one migration file named 20141218140725-create-cafe-owner.js created using the CLI's migration:create command. I used the db:migrate command and it borked giving me this error:

D:\WampDeveloper\Websites\www.example.com\webroot\api_dev>sequelize db:migrate

Sequelize [Node: 0.10.21, CLI: 1.0.0, ORM: 2.0.0-dev9]

Loaded configuration file 'config\config.json'.
[17:24:19] Using sequelizefile ~\AppData\Roaming\npm\node_modules\sequelize-cli\lib\sequelizefile.js
[17:24:19] Starting 'db:migrate'...
[17:24:19] 'db:migrate' errored after 51 ms Unable to resolve the storage: sequelize

D:\WampDeveloper\Websites\www.example.com\webroot\api_dev>

Here's my migration file migrations/20141218140725-create-cafe-owner.js :

"use strict";
module.exports = {
  up: function(migration, DataTypes, done) {
    migration.createTable("CafeOwners", {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: DataTypes.INTEGER
      },
      email: {
        type: DataTypes.STRING(100)
      },
      password: {
        type: DataTypes.STRING(255)
      },
      lastLogin: {
        allowNull: true,
        type: DataTypes.DATE,
      },
      createdAt: {
        allowNull: false,
        type: DataTypes.DATE
      },
      updatedAt: {
        allowNull: false,
        type: DataTypes.DATE
      },
      deletedAt: {
        allowNull: true,
        type: DataTypes.DATE
      },
    }).done(done);
  },
  down: function(migration, DataTypes, done) {
    migration.dropTable("CafeOwners").done(done);
  }
};

For the sake of completeness, here's my config/config.json file as well:

{
  "development": {
    "username": "dbuser",
    "password": "test123",
    "database": "sequelize_test",
    "host": "127.0.0.1",
    "dialect": "mysql"
  },
  "test": {
    "username": "eratest",
    "password": "eratest",
    "database": "sequelize_test",
    "host": "127.0.0.1",
    "dialect": "mysql"
  },
  "production": {
    "username": "ha61gc4e",
    "password": "317e7da87327b3f149b8da90fc1d5746",
    "database": "erasmus",
    "host": "127.0.0.1",
    "dialect": "mysql"
  }
}

I tried to dig through the source, but I am still learning production JS and it seems quite complicated to follow where it's going wrong. After trying to look up this error on Google, I found something about the Sequelize_meta table, but could not find such a table in my database.

Can anyone guide me in the right direction to alleviate this problem?

@sdepold
Copy link
Member

sdepold commented Dec 19, 2014

which version of umzug are you using? This issue should be fixed

@jagged3dge
Copy link
Author

I just installed the cli earlier in the morning today. Going through the internal node_modules folder for this module, I notice that umzug is showing as v1.2.2. Checking the umzug repo, it seems this is the latest build published to npm.

Is there a command-line arg or flag to see stacktrace of an error while running the CLI?

@sdepold
Copy link
Member

sdepold commented Dec 19, 2014

Can you tell me what the result of the following commands are looking like?

mkdir tmp
cd tmp
npm install sequelize-cli sequelize mysql
node_modules/.bin/sequelize init
# please edit the config/config.json accordingly
node_modules/.bin/sequelize db:migrate

@jagged3dge
Copy link
Author

I created a tmp folder, installed all 3 modules like you suggested. Also created a fresh database on MySQL with a dedicated user with password. Updated the config.json file under config/config.json.

Instead of creating a new migration from scratch, i just copied the file from my other project folder. I then ran the command:
node_modules\.bin\sequelize db:migrate

Here's the output:

E:\tmp>node_modules\.bin\sequelize db:migrate

Sequelize [Node: 0.10.21, CLI: 1.0.0, ORM: 2.0.0-rc3]

Loaded configuration file 'config\config.json'.
EventEmitter#success|ok is deprecated, please use promise-style instead.
[15:31:49] Using sequelizefile E:\tmp\node_modules\sequelize-cli\lib\sequelizefile.js
EventEmitter#failure|fail|error is deprecated, please use promise-style instead.

[15:31:49] Starting 'db:migrate'...
Unable to connect to database: Error: Error: ER_ACCESS_DENIED_ERROR: Access denied for user ''@'localhost' (using password: NO)

E:\tmp>

Can't seem to wrap my head around this. Here's my config.json file:

{
  "development": {
    "username": "test",
    "password": "test123",
    "database": "sequelizeclitest",
    "host": "127.0.0.1",
    "dialect": "mysql"
  },
  "test": {
    "username": "test",
    "password": "test123",
    "database": "sequelizeclitest",
    "host": "127.0.0.1",
    "dialect": "mysql"
  },
  "production": {
    "username": "test",
    "password": "test123",
    "database": "sequelizeclitest",
    "host": "127.0.0.1",
    "dialect": "mysql"
  }
}

Here's the MySQL commandline output detailing the test database sequelizeclitest and the user test:

E:\tmp>mysql -u test -p    <~ Username is 'test', as in the config.json file
Enter password: *******    <~ This is 'test123', exactly as it is in the config.json file
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10928
Server version: 5.6.16-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| sequelizeclitest   |    <~ SHOW DATABASES lists the database as in the config.json file
+--------------------+
2 rows in set (0.00 sec)

mysql>

@sdepold
Copy link
Member

sdepold commented Dec 20, 2014

Hmm it doesn't seem to use the password, right? I wonder if this problem is related to windows :-/

@jagged3dge
Copy link
Author

I just tried repeating the same steps on my production server (Amazon EC2 instance with an RHEL AMI). That worked just fine. Here's the output:

[jaggz@xxxzzz temp]# node_modules/.bin/sequelize db:migrate

Sequelize [Node: 0.10.26, CLI: 1.0.0, ORM: 2.0.0-rc3]

Loaded configuration file 'config/config.json'.
Using environment 'development'.
[03:45:25] Using sequelizefile /home/git/temp/node_modules/sequelize-cli/lib/sequelizefile.js
[03:45:25] Starting 'db:migrate'...
EventEmitter#success|ok is deprecated, please use promise-style instead.
EventEmitter#failure|fail|error is deprecated, please use promise-style instead.
[03:45:25] Finished 'db:migrate' after 302 ms
[jaggz@xxxzzz temp]#

You might be right about this problem being related to Windows.

Updating the title of this issue to reflect my windows version. Just for future clarity's sake.

@jagged3dge jagged3dge changed the title Unable to resolve storage 'sequelize' Unable to resolve storage 'sequelize' [on Win7 64-bit] Dec 20, 2014
@sdepold
Copy link
Member

sdepold commented Dec 21, 2014

Alright will give this a try on windows :)

@sdepold
Copy link
Member

sdepold commented Dec 21, 2014

Thanks for the test on a Linux machine!

@jagged3dge
Copy link
Author

Thanks for the test on a Linux machine!

Oh, don't mention it. It's the least I can do since I am not equipped to suggest a fix for this myself >.<
I really really appreciate the work you and the team are putting into developing and maintaining sequelize and its tools.Thank you so much for making the work of people like me easier!

@sdepold
Copy link
Member

sdepold commented Dec 21, 2014

Hmm so this is interesting. I was just running the following stuff on my Win 8.1 machine which uses the github application and its shipped powershell extension (i think its actually just the normal powershell but with some additional paths). I'm running node 0.10.29, cli 1.0.0 and sequelize 2.0.0-rc3. Can you please run the following commands and let me know if you run into any issues?

mkdir tmp
cd tmp
npm install sequelize-cli sequelize mysql
.\node_modules\.bin\sequelize init
# now i changed the config/config.json accordingly
.\node_modules\.bin\sequelize model:create --name foo --attributes name:string
.\node_modules\.bin\sequelize db:migrate

all these commands ran without any issues for me and correctly created two new tables called foos and sequelizemeta.

@mariuszdev
Copy link

I have the same problem on OSX Yosemite and Mavericks.

sequelize db:migrate --coffee
Sequelize [Node: 0.10.32, CLI: 1.0.0, ORM: 2.0.0-rc3, pg: ^4.1.1]

Loaded configuration file 'config/config.json'.
Using environment 'development'.
[22:08:56] Using sequelizefile /usr/local/lib/node_modules/sequelize-cli/lib/sequelizefile.js
[22:08:56] Starting 'db:migrate'...
[22:08:56] 'db:migrate' errored after 155 ms Unable to resolve the storage: sequelize

But... ./node_modules/.bin/sequelize db:migrate --coffee works.

@jagged3dge
Copy link
Author

This surely is getting interesting now. So it works fine on Linux (RHEL tested) & Windows 8.1, but fails on Windows7 & OSX Yosemite.

The plot thickens...

@jagged3dge
Copy link
Author

Just tried creating a model+migration from the CLI before running db:migrate. This time, there's no error message.

E:\tmp>.\node_modules\.bin\sequelize model:create --name foo --attributes name:string

Sequelize [Node: 0.10.21, CLI: 1.0.0, ORM: 2.0.0-rc3]

Loaded configuration file 'config\config.json'.
[04:05:29] Using sequelizefile E:\tmp\node_modules\sequelize-cli\lib\sequelizefile.js
[04:05:29] Starting 'model:create'...
[04:05:29] Finished 'model:create' after 19 ms

E:\tmp>.\node_modules\.bin\sequelize db:migrate

Sequelize [Node: 0.10.21, CLI: 1.0.0, ORM: 2.0.0-rc3]

Loaded configuration file 'config\config.json'.
EventEmitter#success|ok is deprecated, please use promise-style instead.
[04:06:51] Using sequelizefile E:\tmp\node_modules\sequelize-cli\lib\sequelizefile.js
EventEmitter#failure|fail|error is deprecated, please use promise-style instead.

[04:06:51] Starting 'db:migrate'...

E:\tmp>

But there's no success message either. No tables were created.

However, the bright side is that this time it seems to have read the config.json authentication data like it always should, unlike what happened earlier with me and the copied migration file.

@sdepold
Copy link
Member

sdepold commented Dec 22, 2014

@Pilaas you installed it globally right? Will give that setup a try

@sdepold
Copy link
Member

sdepold commented Dec 22, 2014

btw. the fact that it states sequelizefile.js is a bug which results from replacing the string gulp with sequelize

@mariuszdev
Copy link

Sure:

npm ls -g sequelize-cli
/usr/local/lib
└── sequelize-cli@1.0.0

@jagged3dge
Copy link
Author

the fact that it states sequelizefile.js is a bug which results from replacing the string gulp with sequelize

I see. That seems to be affecting regardless of the platform OS. I can see that happening on both my Win7 and Linux boxes and also on OSX Yosemite as @Pilaas

However, I have my doubts regarding the initial problem of the missing sequelize storage being related to this gulpfile issue. Then again, I might be terribly wrong.

@sdepold
Copy link
Member

sdepold commented Dec 22, 2014

no it is not related at all. just wanted to say that

@sdepold
Copy link
Member

sdepold commented Dec 23, 2014

hey @jagged3dge @Pilaas: Can you give it another try with the just released v1.0.1?

@jagged3dge
Copy link
Author

I just checked it out on my local (Win7) machine. I got the AccessDenied Error:

E:\tmp>.\node_modules\.bin\sequelize db:migrate

Sequelize [Node: 0.10.21, CLI: 1.0.1, ORM: 2.0.0-rc4]

Loaded configuration file 'config\config.json'.
EventEmitter#success|ok is deprecated, please use promise-style instead.
[03:11:22] Using sequelizefile E:\tmp\node_modules\sequelize-cli\lib\sequelizefile.js
EventEmitter#failure|fail|error is deprecated, please use promise-style instead.

[03:11:22] Starting 'db:migrate'...
Unable to connect to database: Error: SequelizeAccessDeniedError: ER_ACCESS_DENIED_ERROR: Access denied for user ''@'localhost' (using password: NO)

E:\tmp>

EDIT: Re-checked my config.json. It's still there in config/config.json as the output above states.
Including a copy of it here:


E:\tmp>dir config
 Volume in drive E is Fun
 Volume Serial Number is 0862-4G90

 Directory of E:\tmp\config

12/20/2014  03:27 PM    <DIR>          .
12/20/2014  03:27 PM    <DIR>          ..
12/21/2014  03:42 AM               472 config.json
               1 File(s)            472 bytes
               2 Dir(s)  24,163,102,720 bytes free

E:\tmp>type config\config.json
{
  "development": {
    "username": "test",
    "password": "test123",
    "database": "sequelizeclitest",
    "host": "127.0.0.1",
    "dialect": "mysql"
  },
  "test": {
    "username": "test",
    "password": "test123",
    "database": "sequelizeclitest",
    "host": "127.0.0.1",
    "dialect": "mysql"
  },
  "production": {
    "username": "test",
    "password": "test123",
    "database": "sequelizeclitest",
    "host": "127.0.0.1",
    "dialect": "mysql"
  }
}

E:\tmp>

@sdepold
Copy link
Member

sdepold commented Dec 24, 2014

Can you tell me again which package you installed locally and which globally?

@sdepold sdepold reopened this Dec 24, 2014
@mariuszdev
Copy link

sequelize db:migrate --coffee --env test

Sequelize [Node: 0.10.32, CLI: 1.0.1, ORM: 2.0.0-rc4, pg: ^4.1.1]

Loaded configuration file 'config/config.json'.
Using environment 'test'.
[10:04:08] Using sequelizefile /usr/local/lib/node_modules/sequelize-cli/lib/sequelizefile.js
[10:04:08] Starting 'db:migrate'...
EventEmitter#success|ok is deprecated, please use promise-style instead.
EventEmitter#failure|fail|error is deprecated, please use promise-style instead.
[10:04:08] Finished 'db:migrate' after 144 ms
You have to add "coffee-script" to your package.json.

I have "coffee-script" installed and it is placed in "dependencies" and "devDependencies" as well.

@sdepold
Copy link
Member

sdepold commented Dec 24, 2014

@Pilaas CLI is installed globally everything else locally right? So I have to add another local package resolution for coffee-script.

@mariuszdev
Copy link

Yes, my local stack:

  "dependencies": {
    "coffee-script": "^1.8.0",
    "pg": "^4.1.1",
    "sequelize": "2.0.0-rc4",
  },
  "devDependencies": {
    "coffee-script": "^1.8.0"
  }

And global sequelize-cli:

npm ls -g sequelize-cli
/usr/local/lib
└── sequelize-cli@1.0.1

@jagged3dge
Copy link
Author

Can you tell me again which package you installed locally and which globally?

In my test case, I installed all 3 (sequelize, sequelize-cli & mysql) locally. I did have sequelize-cli installed as global before, but I uninstalled it with npm uninstall -g sequelize-cli before I ran the test scenario following the steps you mentioned previously. I wanted to make sure there was no conflict between versions that way.

@sdepold
Copy link
Member

sdepold commented Dec 26, 2014

@jagged3dge I'm pretty sure that we have 2 different problems here. Your's is somehow related to the CLI not finding your configuration file. And then there is the CLI not finding the coffee-script package

@sdepold
Copy link
Member

sdepold commented Dec 26, 2014

@Pilaas Could you give #76 a try? You need to install js2coffee

@sdepold
Copy link
Member

sdepold commented Dec 27, 2014

Oh wait I think I missed something

@sdepold
Copy link
Member

sdepold commented Dec 27, 2014

@Pilaas alright. fixed the missing piece. Would be cool if you could give it a try

@sdepold
Copy link
Member

sdepold commented Dec 27, 2014

npm install -g 'git://github.com/sequelize/cli.git#hotfix/js2coffee'

@sdepold
Copy link
Member

sdepold commented Dec 30, 2014

@Pilaas should be fixed in 1.0.2

@mariuszdev
Copy link

Sorry mate for not responding.
I'll try 1.0.2 later today and give you feedback. I hope it'll work 👍

@sdepold
Copy link
Member

sdepold commented Dec 30, 2014

me too :)

@mariuszdev
Copy link

I've updated global and local sequelize-cli to 1.0.2. I havent't installed js2coffee.
Should I install it manually ?

Now I have following result:

sequelize db:migrate --coffee

Sequelize [Node: 0.10.32, CLI: 1.0.2, ORM: 2.0.0-rc4, pg: ^4.1.1]

Loaded configuration file 'config/config.json'.
Using environment 'development'.
Unable to find "js2coffee". Please add it to your project.

I'm asking because I wonder if this is what you've wanted.
Shouldn't 10.2 have js2coffee built in ?

@sdepold
Copy link
Member

sdepold commented Dec 30, 2014

Everything that is needed to compile from the existing js to something else is now business of the consumer and therefore it is your job to install js2coffee. I think that makes sense.

PS: js2coffee was removed in 1.0.2 as dependency

@mariuszdev
Copy link

Ok, I've installed js2coffee after my last message and everything works fine.
Will you add info in sequelize-cli's readme.md about necessity of js2coffee installation ?

@sdepold
Copy link
Member

sdepold commented Jan 1, 2015

Ah good point. yes will do that!

@sdepold
Copy link
Member

sdepold commented Jan 1, 2015

@sdepold
Copy link
Member

sdepold commented Jan 2, 2015

@jagged3dge: I just gave this thing another try. My steps:

mkdir tmp
cd .\tmp
npm install sequelize sequelize-cli mysql
.\node_modules\.bin\sequelize init

Note: This prints Sequelize [Node: 0.10.29, CLI: 1.0.2, ORM: 2.0.0-rc4]
Note 2: I created a user test with the password test123 on my windows machine and also database sequelizeclitest.
Note 3: I copied and pasted the config file from your previous comment into my config/config.json so I'm using exactly the same file as you do.

.\node_modules\.bin\sequelize model:create --name User --attributes name:string
.\node_modules\.bin\sequelize db:migrate

The last command results in the following output:

Sequelize [Node: 0.10.29, CLI: 1.0.2, ORM: 2.0.0-rc4]

Loaded configuration file 'config\config.json'.
EventEmitter#success|ok is deprecated, please use promise-style instead.
Using environment 'development'.
EventEmitter#failure|fail|error is deprecated, please use promise-style instead.
[21:23:46] Using sequelizefile ~\Documents\GitHub\tmp\node_modules\sequelize-cli\lib\sequelizefile.js
[21:23:46] Starting 'db:migrate'...
[21:23:46] Finished 'db:migrate' after 563 ms

A quick glance into the db results in this:

screenshot 28

I'm really not sure what is going but everything works perfectly fine for me. Though I'm using Windows 8.1. Can you please execute each of those steps again and show me the output of each step?

@sdepold sdepold added unclear and removed unclear labels Jan 2, 2015
@sdepold
Copy link
Member

sdepold commented Jan 15, 2015

I close this ticket for now. Feel free to re-open it if needed.

@sdepold sdepold closed this as completed Jan 15, 2015
@aysbg
Copy link

aysbg commented Jun 4, 2015

@sdepold I stumbled upon the similar/same issue today:

Sequelize [Node: 0.12.3, CLI: 1.7.0, ORM: 3.1.1]

Loaded configuration file "config/db.json".
Using environment "development".
Using gulpfile /usr/local/lib/node_modules/sequelize-cli/lib/gulpfile.js
Starting 'db:migrate'...
'db:migrate' errored after 17 ms
    at new module.exports.Sequelize (/Users/ays/Sites/gift_connect/web/node_modules/sequelize/lib/sequelize.js:183:13)
    at getSequelizeInstance (/usr/local/lib/node_modules/sequelize-cli/lib/tasks/db.js:203:10)
    at getMigrator (/usr/local/lib/node_modules/sequelize-cli/lib/tasks/db.js:208:21)
    at Object.module.exports.db:migrate.task (/usr/local/lib/node_modules/sequelize-cli/lib/tasks/db.js:23:7)
    at Gulp.gulp.task.aliases (/usr/local/lib/node_modules/sequelize-cli/lib/helpers/gulp-helper.js:14:14)
    at module.exports (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/sequelize-cli/node_modules/gulp/bin/gulp.js:129:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3

My DB is postgres. My config is read fine and it works because I am moving our original, written by hand models, to the migration logic. Thanks for the help man! 😃

@framled
Copy link

framled commented Jun 21, 2017

Same issue over here

Sequelize [Node: 7.10.0, CLI: 2.7.0, ORM: 4.1.0] 
{ 
Error: Access denied for user ''@'localhost' (using password: NO) 
...
code: 'ER_ACCESS_DENIED_ERROR',
     errno: 1045,
     sqlState: '#28000' 
} 

@huseinnashr
Copy link

@framled : That happened because sequelize-cli was using the wrong config.json, just make sure all paths in .sequelizerc point to the correct config file and sequelizer folders.

my .sequelizerc

const path = require('path');

module.exports = {
  "config": path.resolve('./config', 'config.json'),
  "models-path": path.resolve('./models'),
  "seeders-path": path.resolve('./seeders'),
  "migrations-path": path.resolve('./migrations')
};

codetriage-readme-bot pushed a commit to codetriage-readme-bot/cli that referenced this issue Jun 5, 2019
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

Successfully merging a pull request may close this issue.

6 participants