{"action":"created","issue":{"url":"https://api.github.com/repos/db-migrate/node-db-migrate/issues/350","repository_url":"https://api.github.com/repos/db-migrate/node-db-migrate","labels_url":"https://api.github.com/repos/db-migrate/node-db-migrate/issues/350/labels{/name}","comments_url":"https://api.github.com/repos/db-migrate/node-db-migrate/issues/350/comments","events_url":"https://api.github.com/repos/db-migrate/node-db-migrate/issues/350/events","html_url":"https://github.com/db-migrate/node-db-migrate/issues/350","id":132571804,"number":350,"title":"db-migrate up:all fails when using separate scope configurations","user":{"login":"jcowley","id":314126,"avatar_url":"https://avatars.githubusercontent.com/u/314126?v=3","gravatar_id":"","url":"https://api.github.com/users/jcowley","html_url":"https://github.com/jcowley","followers_url":"https://api.github.com/users/jcowley/followers","following_url":"https://api.github.com/users/jcowley/following{/other_user}","gists_url":"https://api.github.com/users/jcowley/gists{/gist_id}","starred_url":"https://api.github.com/users/jcowley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcowley/subscriptions","organizations_url":"https://api.github.com/users/jcowley/orgs","repos_url":"https://api.github.com/users/jcowley/repos","events_url":"https://api.github.com/users/jcowley/events{/privacy}","received_events_url":"https://api.github.com/users/jcowley/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/db-migrate/node-db-migrate/labels/documentation","name":"documentation","color":"207de5"},{"url":"https://api.github.com/repos/db-migrate/node-db-migrate/labels/question","name":"question","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2016-02-09T23:57:13Z","updated_at":"2016-02-14T19:38:38Z","closed_at":null,"body":"The [documentation on scoping ](http://umigrate.readthedocs.org/projects/db-migrate/en/latest/Getting%20Started/the%20commands/?highlight=Scope%20Configuration#scoping) describes using `db-migrate up:all` to execute all scopes. However, this command fails if you use multiple scope configurations.\r\n\r\nHere's my directory structure. \r\n\r\n```\r\nmigrations/\r\n├── scope1/\r\n│   ├── 20160209221257-test-migration.js\r\n│   ├── config.json\r\n│   └── sqls/\r\n│       ├── 20160209221257-test-migration-down.sql\r\n│       └── 20160209221257-test-migration-up.sql\r\n└── scope2/\r\n    ├── 20160209233047-test-migration.js\r\n    ├── config.json\r\n    └── sqls/\r\n        ├── 20160209233047-test-migration-down.sql\r\n        └── 20160209233047-test-migration-up.sql\r\n```\r\nEach config.json file contains the database name like so:\r\n\r\n```json\r\n{\r\n  \"database\": \"my_database_name\"\r\n}\r\n```\r\n\r\nrunning `db-migrate up:scope1` or `db-migrate up:scope2` works fine. However, running `db-migrate up:all` fails with:\r\n\r\n```\r\n[INFO] Enter scope \"/\"\r\n[ERROR] Error: ER_NO_DB_ERROR: No database selected\r\n```\r\n\r\nI'm happy to dig into the source and submit a PR with a fix. However, I just want to confirm that I'm understanding the expected behavior.\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30704666-db-migrate-up-all-fails-when-using-separate-scope-configurations?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/db-migrate/node-db-migrate/issues/comments/183962725","html_url":"https://github.com/db-migrate/node-db-migrate/issues/350#issuecomment-183962725","issue_url":"https://api.github.com/repos/db-migrate/node-db-migrate/issues/350","id":183962725,"user":{"login":"jcowley","id":314126,"avatar_url":"https://avatars.githubusercontent.com/u/314126?v=3","gravatar_id":"","url":"https://api.github.com/users/jcowley","html_url":"https://github.com/jcowley","followers_url":"https://api.github.com/users/jcowley/followers","following_url":"https://api.github.com/users/jcowley/following{/other_user}","gists_url":"https://api.github.com/users/jcowley/gists{/gist_id}","starred_url":"https://api.github.com/users/jcowley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcowley/subscriptions","organizations_url":"https://api.github.com/users/jcowley/orgs","repos_url":"https://api.github.com/users/jcowley/repos","events_url":"https://api.github.com/users/jcowley/events{/privacy}","received_events_url":"https://api.github.com/users/jcowley/received_events","type":"User","site_admin":false},"created_at":"2016-02-14T19:38:38Z","updated_at":"2016-02-14T19:38:38Z","body":"> What happens if you do not specify a scope config?\r\n\r\nI would expect it to fail.\r\n\r\nI'm still trying to wrap my head around the intended purpose of scopes. It would seem that if you're using scopes to separate migrations on different databases, the notion of a \"default scope\" doesn't make sense: e.g. you have 3 databases, which one do you consider the \"default\"? In this type of setup , the current behavior (requiring a \"default\" database) is a bit dangerous. If you forget to drop a config.json in one of your scopes, you apply a bunch of database migrations to the wrong db.\r\n\r\nBut, like I said, I just started using db-migrate so I might be missing some common use cases (or misunderstanding the general purpose of scopes). I'm looking at it from my use case: I have 2 databases, so I'm using scopes to separate the migrations for each of those databases."}}