Use default property values when adding a new column in a migration #1793

segiddins opened this Issue Apr 24, 2015 · 9 comments


None yet

8 participants


No description provided.

@segiddins segiddins added bug P3 labels Apr 24, 2015
@timanglade timanglade added P2 and removed P3 labels Apr 28, 2015
@segiddins segiddins self-assigned this May 7, 2015
@segiddins segiddins removed their assignment Aug 12, 2015
porsager commented Nov 1, 2015

This one bit me as well. Is there any timeframe on this or would it maybe be an idea to note it in the migration documentation?

jpsim commented Nov 5, 2015

I just added this to our docs:

Note that default property values aren't applied to new objects during migrations. We consider this to be a bug and are tracking it as #1793.

rsahara commented Mar 15, 2016

I hope this will be fixed soon as it's difficult for the developers to test if the migrated DB works for each of the previous versions of the realm. (after 90 updates in our case)

We recently received errors because of unexpected null string properties (with normally a default value of @""), when we released a major update of our app.

jpsim commented Jun 20, 2016

The challenge here is to only ever set default values if they haven't explicitly been set by a user, which in turn requires tracking which setters were invoked.

JadenGeller commented Aug 12, 2016 edited

This does seem challenging. I would imagine if a user explicitly set a properties value back to the default, it should not be automatically migrated if the default changes. It almost seems that there ought to be some sort of resetProperty: method.

EDIT: I just realized that this issue only pertains to new columns, which simplifies it.


@jpsim Couldn't we also strictly set the default values before the user sets the property?

jpsim commented Aug 15, 2016

Yes, I think eagerly setting default values before user set the property would be acceptable. It shouldn't have a significant performance impact, but I'd prefer if we checked nonetheless.

@JadenGeller JadenGeller self-assigned this Aug 15, 2016
jemshit commented Dec 2, 2016

So what is solution for assigning default value for new Column after migration ? any magical method ?

@JadenGeller JadenGeller was unassigned by jemshit Dec 2, 2016

No magic. Set manually :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment