We need some sort of upgrade path for the database. If somebody adds a feature now, which requires a database change, a device with an old database wouldn't work properly anymore.
in beroFix we use a database migration path when we update the firmware:
copy the old data to temp-tables
drop the tables
create new tables with default values
re-instert data from the temp-tables
The database needs a version number and the migration skript would check that versionnr. against its own version and would apply all the changes step by step up to most recent version.
another option, which could work is:
export all database content in a datafile
drop the database
create the new database
import all the content again
this would also be very nice, since we would have an export/import for the config than, which we could use for backup&restore.
I've chosen the later option because of the easier handling of importing/exporting the database.
A few things to consider:
After making changes to the database-structure, please increment DB_VERSION
To ensure the functionality of the migration-process, only change the database by adding new stuff (fields, tables) and don't change existing tables if possible.
Setting sane defaults when adding a new field to a table is always a good idea.
Import only works, if the version of the settings to be imported is <= the version of the currently installed database.
Downgrading the database is also not supported.
Things I've tested so far:
Creating a new database (= installing OpenPBX)
Migration of an older database to a newer (one table had an additional column)
We need some sort of upgrade path for the database. If somebody adds a feature now, which requires a database change, a device with an old database wouldn't work properly anymore.
in beroFix we use a database migration path when we update the firmware:
The database needs a version number and the migration skript would check that versionnr. against its own version and would apply all the changes step by step up to most recent version.
another option, which could work is:
this would also be very nice, since we would have an export/import for the config than, which we could use for backup&restore.