Skip to content
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

Migrations #342

Closed
wants to merge 31 commits into from
Closed

Migrations #342

wants to merge 31 commits into from

Conversation

alazier
Copy link
Contributor

@alazier alazier commented May 28, 2014

This pr adds support for Realm migrations.

The basic design is to automatically add new object types and properties without requiring user intervention. When a user updates the schema for an object, they must execute a migration block which returns a new version before opening the realm. During the migration, all new columns and objects are created automatically, and an api is provided to enumerate objects of a given type to allow you to populate new columns from data in the old version of the same object.

As a side effect of these changes, we also needed to change the way we do accessors - instead of doing class replacement for invalid and readonly objects, we now do a check before each call that the accessor is attached and that the realm is writable for mutations. This is needed until c accessors support object level notifications which will allow us to switch back to the other model in the future if desired. Inline methods have been added for getting/setting each type and performing any necessary validation, so that we still only have a single entry point in the code for accessing each type.

@alazier
Copy link
Contributor Author

alazier commented May 28, 2014

Previous discussion: #334

@alazier
Copy link
Contributor Author

alazier commented May 28, 2014

@jpsim commented:

I feel like RLMMigration.schemaVersion should rather be RLMSchema.version. The schema has a version, not the migration. It's Person.dog.age rather than Person.dogAge.

In general I would agree, but in this case the schema pointed to by the realm will change during the course of the migration, so the version number will not remain accurate. The schemaVersion property really indicates the version the schema was at at the beginning of the migration - perhaps we should change the name to reflect this. Ideas?

@jpsim
Copy link
Contributor

jpsim commented May 28, 2014

So how about RLMMigration.initialVersion?

@timanglade
Copy link
Contributor

initialVersion kinda feels like it should be v1

startingVersion or startVersion maybe?

On Wed, May 28, 2014 at 10:42 AM, JP Simard [email protected]:

So how about RLMMigration.initialVersion?


Reply to this email directly or view it on GitHubhttps://github.com//pull/342#issuecomment-44440502
.

@alazier
Copy link
Contributor Author

alazier commented May 28, 2014

oldVersion?

On Wed, May 28, 2014 at 10:45 AM, Tim Anglade [email protected]:

initialVersion kinda feels like it should be v1

startingVersion or startVersion maybe?

On Wed, May 28, 2014 at 10:42 AM, JP Simard [email protected]:

So how about RLMMigration.initialVersion?


Reply to this email directly or view it on GitHub<
https://github.com/realm/realm-objc/pull/342#issuecomment-44440502>
.


Reply to this email directly or view it on GitHubhttps://github.com//pull/342#issuecomment-44440902
.

@jpsim
Copy link
Contributor

jpsim commented May 28, 2014

previousVersion? priorVersion? fromVersion/toVersion?

@alazier
Copy link
Contributor Author

alazier commented May 28, 2014

Thinking about this a bit more, I think we should pass the version into the
migration block - this is more consistent as the migration block also
returns the version. Then it makes sense to call it startingSchemaVersion.

On Wed, May 28, 2014 at 10:49 AM, JP Simard [email protected]:

previousVersion? priorVersion? fromVersion/toVersion?


Reply to this email directly or view it on GitHubhttps://github.com//pull/342#issuecomment-44441433
.

@alazier
Copy link
Contributor Author

alazier commented May 28, 2014

I updated the apis passing the oldVersion into the block. I like this more (hopefully you will agree)

@timanglade
Copy link
Contributor

I like it!

On Wednesday, May 28, 2014, Ari Lazier [email protected] wrote:

I updated the apis passing the oldVersion into the block. I like this more
(hopefully you will agree)


Reply to this email directly or view it on GitHubhttps://github.com//pull/342#issuecomment-44442135
.

@jpsim
Copy link
Contributor

jpsim commented May 29, 2014

Go for it!

@alazier alazier changed the title [WIP] Migrations Migrations Jun 25, 2014
@alazier alazier closed this Jun 25, 2014
@alazier
Copy link
Contributor Author

alazier commented Jun 25, 2014

Closed as all comments are way out of date or already incorporated

@alazier alazier reopened this Jun 25, 2014
@alazier alazier closed this Jun 25, 2014
jpsim pushed a commit that referenced this pull request Sep 27, 2016
Fix auto token refresh issues
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants