Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Adding new field to class during project #9

Open
adipso-jerome opened this issue Mar 24, 2016 · 11 comments
Open

Adding new field to class during project #9

adipso-jerome opened this issue Mar 24, 2016 · 11 comments
Assignees

Comments

@adipso-jerome
Copy link

Hello,
When adding a new field to my class, it seams to not be create into database. If i try to make a print of that new field, it display error "fatal error: unexpectedly found nil while unwrapping an Optional value"

@Oyvindkg
Copy link
Owner

At the moment, migration isn't automated. I have been a little busy the last few months.

I have a few days off now, so I can probably fix it before Saturday, if that would suffice?

@adipso-jerome
Copy link
Author

It's perfect thanks :)

@Oyvindkg
Copy link
Owner

I am spending my Easter deep in the Norwegian mountains, and I seem to have lost my internet connection (writing this on my phone). I'm afraid it will be a little delayed.

As SQLite's ALTER TABLE only supports adding columns and renaming tables, I'm not sure how I want to implement it at the moment.

If you need it asap, or you want to contribute, you are welcome to give it a try and send a pull request! :)

@adipso-jerome
Copy link
Author

ok for the delay, i will wait a little.
Here I find Alter table in sqlite : http://stackoverflow.com/questions/4253804/insert-new-column-into-table-in-sqlite
Sorry, I can't help you, I have already my own project to go ahead :)

@Oyvindkg
Copy link
Owner

If automatic migration is added, I think it should at least support adding and removing columns. This isn't possible using SQLites alter table.

I understand. Best of luck with your project :)

@adipso-jerome
Copy link
Author

Its true, removing is not support by sqlite. Since its a sqlite problem, people will understand that the field they just delete from class won't be delete from table (even if they don't use swiftydb, the problem will be the same).

@groue
Copy link

groue commented Apr 1, 2016

FYI: you can perform any alteration you want to an SQLite table, including removing columns: https://www.sqlite.org/lang_altertable.html#otheralter

@Oyvindkg
Copy link
Owner

Oyvindkg commented Apr 2, 2016

Yes, that would be the naïve, and probably the best approach. As I didn't have a chance to work on this during the Easter due to connection problems, and I am quite busy until May. I'll push a new version as soon as possible

@Oyvindkg Oyvindkg self-assigned this Apr 2, 2016
@Oyvindkg
Copy link
Owner

Oyvindkg commented Apr 2, 2016

The implementation is mostly done, but it needs to be tested

@izouxv
Copy link

izouxv commented Feb 16, 2017

@Oyvindkg
Copy link
Owner

Thank you @izouxv.

2.0 will apply the described process to automatically reflect updated types.

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

No branches or pull requests

4 participants