{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/3327","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/3327/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/3327/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/3327/events","html_url":"https://github.com/realm/realm-java/issues/3327","id":172374743,"number":3327,"title":"Misleading migration example","user":{"login":"mrexmelle","id":6904811,"avatar_url":"https://avatars.githubusercontent.com/u/6904811?v=3","gravatar_id":"","url":"https://api.github.com/users/mrexmelle","html_url":"https://github.com/mrexmelle","followers_url":"https://api.github.com/users/mrexmelle/followers","following_url":"https://api.github.com/users/mrexmelle/following{/other_user}","gists_url":"https://api.github.com/users/mrexmelle/gists{/gist_id}","starred_url":"https://api.github.com/users/mrexmelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrexmelle/subscriptions","organizations_url":"https://api.github.com/users/mrexmelle/orgs","repos_url":"https://api.github.com/users/mrexmelle/repos","events_url":"https://api.github.com/users/mrexmelle/events{/privacy}","received_events_url":"https://api.github.com/users/mrexmelle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-22T05:57:21Z","updated_at":"2016-08-22T07:32:12Z","closed_at":null,"body":"\r\n#### Goal\r\n\r\n> Providing a correct example to the developers who want to implement Realm migration procedure.\r\n\r\n#### Expected Results\r\n\r\n> When a developer wants to upgrade from version 1 to version 2, only one migration should take place, i.e. migration from 1 to 2.\r\n\r\n#### Actual Results\r\n\r\n>  When a developer wants to upgrade from version 1 to version 2, the migration continues until version 3. \r\n\r\n#### Steps & Code to Reproduce\r\n\r\n> Clear enough.\r\n\r\n#### Code Sample\r\n\r\n## Currently\r\n```java\r\n\r\nif(oldVersion == 0)\r\n{\r\n // migration from version 0 to 1 takes place\r\n oldVersion++;\r\n}\r\n\r\nif(oldVersion == 1)\r\n{\r\n // migration from version 1 to 2 takes place\r\n oldVersion++;\r\n}\r\n\r\nif(oldVersion == 2)\r\n{\r\n // migration from version 2 to 3 takes place\r\n oldVersion ++;\r\n}\r\n\r\n```\r\n\r\n## Expected\r\n```java\r\n\r\nif(oldVersion == 0 && oldVersion<newVersion)\r\n{\r\n // migration from version 0 to 1 takes place\r\n oldVersion++;\r\n}\r\n\r\nif(oldVersion == 1 && oldVersion<newVersion)\r\n{\r\n // migration from version 1 to 2 takes place\r\n oldVersion++;\r\n}\r\n\r\nif(oldVersion == 2 && oldVersion<newVersion)\r\n{\r\n // migration from version 2 to 3 takes place\r\n oldVersion ++;\r\n}\r\n\r\n```\r\n\r\n#### Version of Realm and tooling\r\nRealm version(s): 1.1.1\r\n\r\nAndroid Studio version: 2.1.3\r\n\r\nWhich Android version and device: Any\r\n"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/241334489","html_url":"https://github.com/realm/realm-java/issues/3327#issuecomment-241334489","issue_url":"https://api.github.com/repos/realm/realm-java/issues/3327","id":241334489,"user":{"login":"spl","id":54900,"avatar_url":"https://avatars.githubusercontent.com/u/54900?v=3","gravatar_id":"","url":"https://api.github.com/users/spl","html_url":"https://github.com/spl","followers_url":"https://api.github.com/users/spl/followers","following_url":"https://api.github.com/users/spl/following{/other_user}","gists_url":"https://api.github.com/users/spl/gists{/gist_id}","starred_url":"https://api.github.com/users/spl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spl/subscriptions","organizations_url":"https://api.github.com/users/spl/orgs","repos_url":"https://api.github.com/users/spl/repos","events_url":"https://api.github.com/users/spl/events{/privacy}","received_events_url":"https://api.github.com/users/spl/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T07:32:11Z","updated_at":"2016-08-22T07:32:11Z","body":"I think adding the `oldVersion < newVersion` condition to every `if` is misleading. That's not to say that the examples or documentation couldn't be improved, as I suggested in #3165.\r\n\r\nPerhaps it would help to add statements to the effect of:\r\n\r\n* migrations are intended to bring any previous version of the schema up to date with the latest and\r\n* if you want to test migration to a particular version during development, you may need to use a different approach."}}
{"actor":{"display_login":"spl"}}