{"action":"opened","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/3694","repository_url":"https://api.github.com/repos/realm/realm-cocoa","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3694/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3694/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/3694/events","html_url":"https://github.com/realm/realm-cocoa/issues/3694","id":158059569,"number":3694,"title":"schemaVersion not saved after data migration","user":{"login":"xiaodao","id":173646,"avatar_url":"https://avatars.githubusercontent.com/u/173646?v=3","gravatar_id":"","url":"https://api.github.com/users/xiaodao","html_url":"https://github.com/xiaodao","followers_url":"https://api.github.com/users/xiaodao/followers","following_url":"https://api.github.com/users/xiaodao/following{/other_user}","gists_url":"https://api.github.com/users/xiaodao/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaodao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaodao/subscriptions","organizations_url":"https://api.github.com/users/xiaodao/orgs","repos_url":"https://api.github.com/users/xiaodao/repos","events_url":"https://api.github.com/users/xiaodao/events{/privacy}","received_events_url":"https://api.github.com/users/xiaodao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-02T04:58:23Z","updated_at":"2016-06-02T04:58:23Z","closed_at":null,"body":"Realm version: 0.98.6\r\n\r\nI'm using the following code to check if we should do migration or not:\r\n\r\n```\r\n  func shouldDoMigration() -> Bool {\r\n    let config = RLMRealmConfiguration.defaultConfiguration()\r\n    let storeURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(\"app.id\")\r\n    let realmURL = storeURL?.URLByAppendingPathComponent(\"defaut.realm\")\r\n    config.path = realmURL?.path\r\n\r\n    print(\"should do migration? config path: \\(config.path)\")\r\n    print(\"config.schemaVersion: \\(config.schemaVersion)\")\r\n    return config.schemaVersion < 1\r\n  }\r\n```\r\n\r\nand use the following code to do migration:\r\n\r\n```\r\nfunc migrateWithCompletion() {\r\n    let config = RLMRealmConfiguration.defaultConfiguration()\r\n    let storeURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(\"app.id\")\r\n    let realmURL = storeURL?.URLByAppendingPathComponent(\"default.realm\")\r\n    config.path = realmURL?.path\r\n    print(\"migrating? config path: \\(config.path)\")\r\n\r\n    config.schemaVersion = 1\r\n\r\n    config.migrationBlock = { (migration, oldSchemaVersion) in\r\n      if (oldSchemaVersion < 1) {\r\n        // Nothing to do!\r\n        // Realm will automatically detect new properties and removed properties\r\n        // And will update the schema on disk automatically\r\n      }\r\n    }\r\n\r\n    RLMRealmConfiguration.setDefaultConfiguration(config)\r\n    print(\"schemaVersion after migration:\\(RLMRealmConfiguration.defaultConfiguration().schemaVersion)\")\r\n    RLMRealm.defaultRealm()\r\n  }\r\n```\r\n\r\nAnd I see shouldDoMigration() always returns true and `config.schemaVersion:` always return 0, even if this statement `print(\"schemaVersion after migration:\\(RLMRealmConfiguration.defaultConfiguration().schemaVersion)\")` prints 1. \r\n\r\nIs here anything wrong in the code above? "}}
{"actor":{"display_login":"xiaodao"}}