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 · 11 comments

Comments

Projects
None yet
@segiddins
Contributor

segiddins commented Apr 24, 2015

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

This comment has been minimized.

Show comment
Hide comment
@porsager

porsager Nov 1, 2015

Contributor

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?

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

This comment has been minimized.

Show comment
Hide comment
@jpsim

jpsim Nov 5, 2015

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@rsahara

rsahara 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.

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

This comment has been minimized.

Show comment
Hide comment
@jpsim

jpsim Jun 20, 2016

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@JadenGeller

JadenGeller Aug 12, 2016

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@JadenGeller

JadenGeller Aug 12, 2016

Contributor

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

Contributor

JadenGeller commented Aug 12, 2016

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

@jpsim

This comment has been minimized.

Show comment
Hide comment
@jpsim

jpsim Aug 15, 2016

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@jemshit

jemshit Dec 2, 2016

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

jemshit commented Dec 2, 2016

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

@werediver

This comment has been minimized.

Show comment
Hide comment
@werediver

werediver Dec 2, 2016

No magic. Set manually :(

werediver commented Dec 2, 2016

No magic. Set manually :(

@mrgcohen

This comment has been minimized.

Show comment
Hide comment
@mrgcohen

mrgcohen commented Jan 22, 2018

@guhan0

This comment has been minimized.

Show comment
Hide comment
@guhan0

guhan0 Sep 4, 2018

Any solution or fix to this issue?

guhan0 commented Sep 4, 2018

Any solution or fix to this issue?

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