Skip to content

sqlite database upgrade without losing user data #687

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

Closed
mik-ro opened this issue Jul 16, 2017 · 1 comment
Closed

sqlite database upgrade without losing user data #687

mik-ro opened this issue Jul 16, 2017 · 1 comment
Labels

Comments

@mik-ro
Copy link

mik-ro commented Jul 16, 2017

Let's say I have a quiz app and there are two tables in my database. In the first table(questions_table) there are quiz questions. That database is bundled in my app and the file is located in Documents directory.

In the second table(starred_questions_table) there are questions starred by users. It is created when the app starts and then populated by the users which star the tough questions.

Now I want to make an update for my app and add more quiz questions to my database(questions_table). So I add a new db file to the bundle but I also don't want in any case that my users lost their starred questions when they update the app. What's the best way to solve this problem?

If I move new database file(from bundle) to documents folder the previous file(with starred questions) will be lost. Should I make two simultaneous connections(one to database file in Bundle and second to old database file in Documents) and copy just new records from questions_table to documents directory?

@jberkel
Copy link
Collaborator

jberkel commented Sep 28, 2017

Another option could be to use two different databases, and then use ATTACH/DETACH (#30)

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

No branches or pull requests

2 participants