{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/6355","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/6355/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/6355/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/6355/events","html_url":"https://github.com/realm/realm-java/issues/6355","id":385165259,"node_id":"MDU6SXNzdWUzODUxNjUyNTk=","number":6355,"title":"Issue with Realm migration on custom configuration","user":{"login":"abayomiAkanji","id":17466943,"node_id":"MDQ6VXNlcjE3NDY2OTQz","avatar_url":"https://avatars2.githubusercontent.com/u/17466943?v=4","gravatar_id":"","url":"https://api.github.com/users/abayomiAkanji","html_url":"https://github.com/abayomiAkanji","followers_url":"https://api.github.com/users/abayomiAkanji/followers","following_url":"https://api.github.com/users/abayomiAkanji/following{/other_user}","gists_url":"https://api.github.com/users/abayomiAkanji/gists{/gist_id}","starred_url":"https://api.github.com/users/abayomiAkanji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abayomiAkanji/subscriptions","organizations_url":"https://api.github.com/users/abayomiAkanji/orgs","repos_url":"https://api.github.com/users/abayomiAkanji/repos","events_url":"https://api.github.com/users/abayomiAkanji/events{/privacy}","received_events_url":"https://api.github.com/users/abayomiAkanji/received_events","type":"User","site_admin":false},"labels":[{"id":662397242,"node_id":"MDU6TGFiZWw2NjIzOTcyNDI=","url":"https://api.github.com/repos/realm/realm-java/labels/O:User","name":"O:User","color":"006b75","default":false},{"id":3545600,"node_id":"MDU6TGFiZWwzNTQ1NjAw","url":"https://api.github.com/repos/realm/realm-java/labels/T:Help","name":"T:Help","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-28T09:02:40Z","updated_at":"2018-11-29T06:52:38Z","closed_at":null,"author_association":"NONE","body":"I was trying to migrate a realm DB with *custom configuration* but it keeps throwing same error that exist before implementing the migration class.\r\n\r\nHere are my code snippets\r\n\r\nRealm configuration:\r\n```\r\nprivate fun getRealm(): Realm {\r\n       val config = RealmConfiguration.Builder()\r\n               .name(DB_NAME)\r\n               .encryptionKey(key)\r\n               .schemaVersion(2)\r\n               .migration(DbMigration())\r\n               .build()\r\n\r\n       return Realm.getInstance(config)\r\n   }\r\n```\r\n\r\nHere is my migration class:\r\n```\r\npublic class DbMigration implements RealmMigration {\r\n\r\n   @Override\r\n   public void migrate(@NotNull final DynamicRealm realm, long oldVersion, long newVersion) {\r\n       RealmSchema schema = realm.getSchema();\r\n\r\n       if(oldVersion == 1){\r\n           RealmObjectSchema receiptLineSchema = schema.get(AggregationReceiptLine.class.getSimpleName());\r\n           receiptLineSchema.addField(\"payablePrice\", double.class);\r\n           receiptLineSchema.addField(\"transactionFee\", double.class);\r\n           oldVersion++;\r\n       }\r\n   }\r\n}\r\n```\r\n\r\nAnd this is the error log despite adding the new fields in the **migrate** method of the migration class.\r\n```\r\nCaused by: io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors:\r\n   - Property 'AggregationReceiptLine.payablePrice' has been added.\r\n   - Property 'AggregationReceiptLine.transactionFee' has been added.\r\n```"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/442725828","html_url":"https://github.com/realm/realm-java/issues/6355#issuecomment-442725828","issue_url":"https://api.github.com/repos/realm/realm-java/issues/6355","id":442725828,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MjcyNTgyOA==","user":{"login":"abayomiAkanji","id":17466943,"node_id":"MDQ6VXNlcjE3NDY2OTQz","avatar_url":"https://avatars2.githubusercontent.com/u/17466943?v=4","gravatar_id":"","url":"https://api.github.com/users/abayomiAkanji","html_url":"https://github.com/abayomiAkanji","followers_url":"https://api.github.com/users/abayomiAkanji/followers","following_url":"https://api.github.com/users/abayomiAkanji/following{/other_user}","gists_url":"https://api.github.com/users/abayomiAkanji/gists{/gist_id}","starred_url":"https://api.github.com/users/abayomiAkanji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abayomiAkanji/subscriptions","organizations_url":"https://api.github.com/users/abayomiAkanji/orgs","repos_url":"https://api.github.com/users/abayomiAkanji/repos","events_url":"https://api.github.com/users/abayomiAkanji/events{/privacy}","received_events_url":"https://api.github.com/users/abayomiAkanji/received_events","type":"User","site_admin":false},"created_at":"2018-11-29T06:52:38Z","updated_at":"2018-11-29T06:52:38Z","author_association":"NONE","body":"Hi @cmelchior how does Realm handle migration when user does not install all versions of the app, hence, missing some migration **schemaVersions**\r\n\r\n_Example:_\r\nThe app has **schemaVersion 1** as the first time user installs app. The next time user updates app, the **schemaVersion** has become **3**. How does Realm handle the migration in such a way that user who jumps from **schemaVersion 1** to **3** would not miss the _migration info_ in **schemaVersion 2**"}}
{"actor":{"display_login":"abayomiAkanji"}}