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

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

Open
segiddins opened this issue Apr 24, 2015 · 12 comments
Open

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

segiddins opened this issue Apr 24, 2015 · 12 comments

Comments

@segiddins
Copy link
Contributor

No description provided.

@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
Copy link
Contributor

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
Copy link
Contributor

jpsim commented Nov 5, 2015

I just added this to our docs: https://realm.io/docs/objc/latest/#migrations

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
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

JadenGeller commented Aug 12, 2016

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.

@JadenGeller
Copy link
Contributor

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

@jpsim
Copy link
Contributor

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.

@jemshit
Copy link

jemshit commented Dec 2, 2016

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

@werediver
Copy link

No magic. Set manually :(

@mrgcohen
Copy link

setting manually (reference)
https://realm.io/docs/swift/latest/#updating-values

@guhan0
Copy link

guhan0 commented Sep 4, 2018

Any solution or fix to this issue?

@ThreadPitt
Copy link

ThreadPitt commented Mar 8, 2019

Still happens here, any progress on this?
Please, pretty PLEASE :-)

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

No branches or pull requests