Opened 5 years ago
Closed 5 years ago
Verify TV Database Schema Version on startup
|Reported by:||sphery <mtdean@…>||Owned by:||cpinkham|
The attached patch, mythtv-verify_schema_version.patch , prevents mythfrontend from upgrading the schema version and prevents an "old" mythbackend or mythtv-setup from running against a newer schema version than it understands. With the new autodetection code, allowing mythfrontend to upgrade the schema version could have undesired consequences. Also, allowing mythbackend or mythtv-setup to change data in a database with a different schema than expected could result in corrupted data.
Rather than modify UpgradeTVDatabaseSchema() to accept a bool upgradeAllowed (default true) and call it from mythfrontend as UpgradeTVDatabaseSchema(false), which would only handle preventing mythfrontend from upgrading the schema, I added a new function, CheckTVDatabaseSchema() in libs/libmythtv/dbcheck.cpp. A separate call to this new function before calling UpgradeTVDatabaseSchema() allows preventing old backends and mythtv-setup (which are allowed to upgrade the schema) from running when they don't understand the schema version (i.e. old backend/mythtv-setup shouldn't modify data in the DB if they don't know about future changes to the schema).
To allow frontend-only users (i.e. those using MythVideo/MythMusic?, but not using any TV functionality) to upgrade the schema, there is a new command-line argument for mythfrontend, --upgrade-schema, that allows it to upgrade the schema. Alternatively, those users may simply run mythtv-setup or mythbackend to upgrade the database.
The patch supports MythContext::PromptForSchemaUpgrade?()'s "expertMode" (DBSchemaAutoUpgrade=-1). In this mode, it will allow running an old mythbackend/mythtv-setup/mythfrontend against a newer schema version. Since the patch doesn't prevent mythbackend or mythtv-setup from upgrading the database, it would still be possible to run them against an old schema version with expertMode. However, since it tries to prevent mythfrontend from upgrading the schema version, enabling expertMode explicitly enables mythfrontend to upgrade the schema version (and, therefore, would also allow mythfrontend to run against and old schema version).
Change History (4)
Changed 5 years ago by sphery <mtdean@…>
comment:1 Changed 5 years ago by cpinkham
- Owner changed from ijr to cpinkham
- Status changed from new to assigned
comment:2 Changed 5 years ago by cpinkham
- Milestone changed from unknown to 0.21
- Priority changed from minor to critical
- Severity changed from medium to high
comment:3 Changed 5 years ago by cpinkham
- Resolution set to fixed
- Status changed from assigned to closed