mercredi 21 octobre 2015

Simple version support for tables in SQLite database

We are using SQLite database. We need to add simple version support to the tables

Requirement: Say the DB has Table1 with 2 Rows and 2 Columns. This is stored in memory. Now if we need to update the software so that the Table1 will have 2 Rows and 3 Columns. After software update at power up the old table should be deleted and new table should be created with 3 columns.

Proposed Solution: Create a new table named version_table. This will store the version number of all other tables. The software will have the version number for all tables in a header file.

If table1 is updated then the version_table will be updated and the software will be updated. After this the version number for table1 will be 2.

When the new software is loaded the old database with table1(Row:2, column:2) still present in memory. The software connects to the DB, checks the version number for table1 in version_table in DB. It will be 1. In the new software in the header file the version for table1 will be 2.

Since there is a mismatc the table will be recreated. If there is no mismatch the table will not be recreated.

I would like to know is there any other better way of doing this?

Aucun commentaire:

Enregistrer un commentaire