Skip to content

sqlite database upgrade without losing user data #687

Closed
@mik-ro

Description

@mik-ro

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions