-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RLMRealm] added +migrationRequiredAtPath:encryptionKey:error: #1723
Conversation
} | ||
} | ||
for (RLMObjectSchema *objectSchema in [[RLMSchema sharedSchema] objectSchema]) { | ||
RLMObjectSchema *tableSchema = [RLMObjectSchema schemaFromTableForClassName:objectSchema.className realm:realm]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure you test this works when tableSchema == nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't. Should just continue if tableSchema
is nil (since creating missing tables doesn't require a migration).
Returns whether or not the realm at the given path can be accessed without performing a migration. | ||
|
||
@param realmPath Path to a Realm file. | ||
@param key 64-byte encryption key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"64-byte encryption key or nil for unencrypted Realms."
It's not optional most of the places where there's a key parameter, so it needs to call out that this one is.
3201653
to
ef95c01
Compare
I don't think this is the correct solution for #1692 The user of this issue should still be setting a schema version, and we should provide a mechanism to clear the Realm in case the migration is required and run. With this pr you are encouraging the user manually delete files which is very error prone, and you are also teaching them that ignoring schema version is ok in some cases (which it really isn't). Instead of this pr we should instead add a mechanism to clear the realm safely, and this user should update the schema version when they make schema changes. |
I like the idea of a safe realm deletion method, which would take care of checking if there are any open db connections, perhaps even closing them, before deleting all the relevant files. I think we need that regardless of what we do. However, I do think letting users to know if their realm files require a migration will give them much more flexibility to migrate, delete or otherwise make better informed decisions about what to do with their realms at runtime. I understand that we want to minimize the odds of accidental deletion, which is why I'd rather not add |
I don't think incrementing a schema version is really that much of a burden, it's literally changing one constant somewhere in your app. |
Let's revisit & try and get this merged? |
…equiredAtPath() free function
66ced6a
to
f0145d3
Compare
This has been updated and is ready for review again /cc @segiddins @tgoyne @bdash |
Closing in favor of #1584 (comment). |
@jpsim is this method public? I can't find it to check if my realm needs a migration or not. |
@natanrolnik, no this PR was closed without merging. We opted to go with #1584 (comment) instead, although that has yet to be implemented. |
Fixes #1692. /cc @alazier @tgoyne @segiddins