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

Migrations only seem to work for the 'admin' database #46

Open
dwhelan opened this issue Mar 3, 2017 · 2 comments
Open

Migrations only seem to work for the 'admin' database #46

dwhelan opened this issue Mar 3, 2017 · 2 comments

Comments

@dwhelan
Copy link

dwhelan commented Mar 3, 2017

I am new to mongo and mongodb-migrations so I'm not sure I am doing something wrong but I noted the following:

Using the following migration file:

# 1-test.js

'use strict';

module.exports.id = "test";

module.exports.up = function (done) {
  this.log("up 1");
  done();
};

module.exports.down = function (done) {
  this.log("down 1");
  done();
};

and

# mm-config.json

{
  "url": "mongodb://localhost:27017/test",
  "directory": "migrations"
}

When I run the migration everything looks ok on the command line:

$ ./node_modules/.bin/mm migrate
   up 1
     Migration 'test': ok

But when I query the _migrations collection from mongo command line I get:

> db._migrations.find
2017-03-02T23:40:28.320-0500 E QUERY    [thread1] TypeError: db._migrations is undefined :
@(shell):1:1
>

The screenshot below also shows something odd from MongoDB Compass where the _migrations collection is not shown under the test db on the left panel yet shows up as a collection in the right panel. If I click on the _migrations collection in the right panel I get the error notification you see in the top right corner.

It seems like the collection is not created properly in the test db.
screenshot 2017-03-02 23 50 38

@droidpl
Copy link

droidpl commented Sep 11, 2017

I manage to make it work by using the following mm-config:

{
  "url": "mongodb://admin:adminPass@yourHost:yourPort/yourDb",
  "options": {
    "authSource": "admin"
  }
}

@nicolasmure
Copy link

nicolasmure commented Jan 4, 2018

In a mongo shell :

> db.getCollection("_migrations").find({})

is working, whereas

> db._migrations.find({})

is not.
Looks like it's a mongo bug : https://stackoverflow.com/questions/24309685/mongo-client-cant-access-collections-prefixed-with-an-underscore

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

3 participants