Re: [realm-cocoa] Rollback migration

46 views
Skip to first unread message

Ari Lazier

unread,
Jan 15, 2015, 4:42:04 PM1/15/15
to Rohan Seth, realm...@googlegroups.com
Glad you figured it out!

--
Ari Lazier



On Thu, Jan 15, 2015 at 7:32 PM UTC, Rohan Seth <ro...@gmail.com> wrote:
Ah, nevermind. There's a WHOLE lot of things wrong with our migration code.
Sorry!



On Thu, Jan 15, 2015 at 7:24 PM UTC, Rohan Seth <ro...@gmail.com> wrote:
Is there a way to rollback a migration? We had a bug in our code that left us in an unrecoverable state.

Here's what happened:
-- Added an additional field to the schema
-- Upped the schema version, but put the newObject["newField"] in the wrong place (put it as part of the previous version's migration -- ugh I know)
-- Now, when we run the app, it crashes with "Migration is required. Property 'newField' has been added to the latest object model"

We tried to run another empty migration by just upping the schema number, but the code crashes even before the [RLMRealm setSchemaVersion] call.

Any ideas?

Thanks!
--
You received this message because you are subscribed to the Google Groups "Realm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-cocoa...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-cocoa/14276300-4714-4bd3-a88d-97cb14b6c89f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:65798558-319#}

John Dzak

unread,
Dec 18, 2015, 12:15:42 PM12/18/15
to Realm, ro...@gmail.com, he...@realm.io
Hey,

I just stumbled upon this post while trying to figure out if there's a way to rollback a migration. Does anyone know if it's possible?

The situation I have is that I want to experiment by adding or deleting properties to my models which requires me to bump the schema version bumps for each change. At the end of my experimentation, I only want to push a single schema migration back to the main codebase (so not to confuse other people with my experimentation).

Any other ideas are welcome too.

Thanks,
John

Marius Rackwitz

unread,
Dec 21, 2015, 10:39:57 AM12/21/15
to John Dzak, realm...@googlegroups.com, ro...@gmail.com
Hey John,

no there is no public API, which allows to rollback a schema migration.
For such local experimentations as you describe your use case, this doesn't seem to be necessary.
I'd recommend that you create a seed file with the current schema of the code base and bundle that with your application and just replace the stored file on launch every time. So you can make modifications, but always start from what you currently have. In that way, you can make sure that your migrations will work as expected from the original schema and not from just an intermediate schema version, which you will never publish.

Hope this helps!

Best Regards,

Marius

--
Marius Rackwitz
iOS Product Engineer
{#HS:151374212-2505#}

John Dzak

unread,
Dec 21, 2015, 10:43:41 AM12/21/15
to realm...@googlegroups.com
Thanks Marius. Great idea.
Reply all
Reply to author
Forward
0 new messages