{"action":"created","issue":{"url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4491","repository_url":"https://api.github.com/repos/reactioncommerce/reaction","labels_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4491/labels{/name}","comments_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4491/comments","events_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4491/events","html_url":"https://github.com/reactioncommerce/reaction/pull/4491","id":344983499,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0MjQ5NTk0","number":4491,"title":"Fix migration error preventing app startup","user":{"login":"impactmass","id":5229321,"node_id":"MDQ6VXNlcjUyMjkzMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/5229321?v=4","gravatar_id":"","url":"https://api.github.com/users/impactmass","html_url":"https://github.com/impactmass","followers_url":"https://api.github.com/users/impactmass/followers","following_url":"https://api.github.com/users/impactmass/following{/other_user}","gists_url":"https://api.github.com/users/impactmass/gists{/gist_id}","starred_url":"https://api.github.com/users/impactmass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/impactmass/subscriptions","organizations_url":"https://api.github.com/users/impactmass/orgs","repos_url":"https://api.github.com/users/impactmass/repos","events_url":"https://api.github.com/users/impactmass/events{/privacy}","received_events_url":"https://api.github.com/users/impactmass/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-26T19:55:18Z","updated_at":"2018-07-27T01:34:49Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/4491","html_url":"https://github.com/reactioncommerce/reaction/pull/4491","diff_url":"https://github.com/reactioncommerce/reaction/pull/4491.diff","patch_url":"https://github.com/reactioncommerce/reaction/pull/4491.patch"},"body":"Resolves #4362   \r\nImpact: **major**  \r\nType: **fix**\r\n\r\n## Issue\r\nIf you move to the current version and then decide you need to roll back for any reason, and that newer version contained a migration, the app will not start, and you get an error similar to:\r\n```\r\nweb_1  | /app/programs/server/node_modules/fibers/future.js:280\r\nweb_1  | \t\t\t\t\t\tthrow(ex);\r\nweb_1  | \t\t\t\t\t\t^\r\nweb_1  | Error: [Can't find migration version 26]\r\n```\r\n## Solution\r\n- Added a check to to compare the existing migration version with available code migration before running migrations. So, we only call `migrateTo(\"latest\")` when it's actually possible to migrate higher. (as [suggested on issue ](https://github.com/reactioncommerce/reaction/issues/4362#issuecomment-403872554))\r\n- Also added a log.warn with text: `You are running a Reaction version with migration version (${highestAvailableVersion}) below your current DB migration state (${currentMigrationVersion})`\r\n\r\n## Breaking changes\r\nNone that I'm aware of.\r\n\r\n## Testing\r\n1. Run the app on release-1.14.0 branch. This currently had migrations to version 32. So when the app starts, it should migrate to v32.\r\n2. Checkout into master. But before you start the app, you'll need to copy the contents of this file (`/imports/plugins/core/versions/server/startup.js`) on this branch into your master. I know this might feel weird, but since moving to master contains the lesser migration code, this fix needs to be copied to the branch to confirm that it works.\r\n3. Start the app and confirm that there are no migration errors, and there's a Log warn message about migration version\r\n\r\nAlternative way to test:\r\n- Start the app on this branch.\r\n- Connect to your DB, and increment the version number of the only Migration collection document. \r\n- After incrementing, restart the app\r\n- Confirm that there are no migration errors, and there's a Log warn message about migration version"},"comment":{"url":"https://api.github.com/repos/reactioncommerce/reaction/issues/comments/408284563","html_url":"https://github.com/reactioncommerce/reaction/pull/4491#issuecomment-408284563","issue_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4491","id":408284563,"node_id":"MDEyOklzc3VlQ29tbWVudDQwODI4NDU2Mw==","user":{"login":"zenweasel","id":72819,"node_id":"MDQ6VXNlcjcyODE5","avatar_url":"https://avatars1.githubusercontent.com/u/72819?v=4","gravatar_id":"","url":"https://api.github.com/users/zenweasel","html_url":"https://github.com/zenweasel","followers_url":"https://api.github.com/users/zenweasel/followers","following_url":"https://api.github.com/users/zenweasel/following{/other_user}","gists_url":"https://api.github.com/users/zenweasel/gists{/gist_id}","starred_url":"https://api.github.com/users/zenweasel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenweasel/subscriptions","organizations_url":"https://api.github.com/users/zenweasel/orgs","repos_url":"https://api.github.com/users/zenweasel/repos","events_url":"https://api.github.com/users/zenweasel/events{/privacy}","received_events_url":"https://api.github.com/users/zenweasel/received_events","type":"User","site_admin":false},"created_at":"2018-07-27T01:34:49Z","updated_at":"2018-07-27T01:34:49Z","author_association":"MEMBER","body":"@impactmass Could I test this by just adding a dummy migration, starting the app, and then removing it?\r\n\r\nI think @aldeed had also mentioned that stopping the app from running might be the expected behavior rather than letting the user run the app with the database in an unknown state. I see good arguments for each, but I would def bump the Log level to `error` or `fatal` because there is not-small chance your app will completely not work."}}
{"actor":{"display_login":"zenweasel"}}