1

In my Flutter app, I am using a SQLite database. Its name is "quiz.db" and I shall place it in the this location: assets/quiz.db

Suppose it is a quiz app and there are two tables:

(1) quiz_questions

(2) performance_records

In the "quiz_questions" table, I shall store all the quiz questions.

In the "performance_records" table, I shall store the quiz results of the app user so that I can show the app user how she is performing over time. Every time the user submits her answer, I shall add a row to the "performance_records" table to record this result.

Every month I shall add more questions to the "quiz_questions" table when I upload the new version of my app. I can do this by two ways - (1) adding new questions to the existing "quiz_questions" table or (2) replacing it with a fresh, new and complete "quiz_questions" table.

I do not want to change anything in the "performance_records" table when the user upgrades to the new version of my app.

So, here is what I need to know:

*** How can I replace or add new questions to the "quiz_questions" table in every new version/release of my app without making any change to the "performance_records" table?

Any suggestions?

Tanzilo
  • 51
  • 1
  • 1
    You can use database migrations (a series of SQL statements) to alter the existing database, add rows, delete rows. All migration files would need to be part of your app. You'd need to keep track of which migrations have run (e.g. in a migrations table, that stores each filename of processed migrations), and only process migrations not in that list Here is an example: https://stackoverflow.com/a/63105852/12132021 – Jared Anderton Nov 11 '21 at 07:06

0 Answers0