I'm reading DBAccess documentation to understand if it can fit my needs.
My question is about migration.
For example: I have an existing app, implemented with DBAccess, using a table "Person" with the following fields:
- id
- name
- surname
- address
What happens to database if I add other two fields to Person class:
- email
- phone_number
?
Does DBAccess automatically add new fields to database table?
Is there a way to specifiy default values for new added fields?
Yes, if you add those two additional properties DBAccess will automatically add the additional columns.
At present, there is no ability to specify a default value for the new columns, they will all be initialised with NULL as you would expect.
Your suggestion about default values is interesting, i'm surprised that has not come up before. It seems both easy to implement and quite a logical feature. The only small weird thing would be that if I were to add the method
+ (id)defaultValueForProperty:(NSString*)propertyName;
to the framework, and then called that when creating a new column, would users perhaps expect this to happen per row and not once when creating a column, so they can customise that value, perhaps calculate it from contents elsewhere.
I would enjoy your feedback as to what you feel would be an appropriate solution.
I am personally leaning towards both a class and an instance method, and if the developer implements an instance method, then every individual row will be parsed and re-written which could be slow, but also a very useful feature.
Either way, it shouldn't take more than an hour or so for such a simple feature to be added. We just need to see if we can see any pitfalls.
Thanks