10
9
#include "metadata.h"
11
10
#include "mythtv/mythcontext.h"
12
11
#include "mythtv/mythdb.h"
12
#include "mythtv/schemawizard.h"
14
14
const QString currentDatabaseVersion = "1017";
16
static bool doUpgradeMusicDatabaseSchema(QString &dbver);
16
18
static bool UpdateDBVersionNumber(const QString &newnumber)
67
69
bool UpgradeMusicDatabaseSchema(void)
69
QString dbver = gContext->GetSetting("MusicDBSchemaVer");
71
if (dbver == currentDatabaseVersion)
71
SchemaUpgradeWizard * DBup;
74
gContext->ActivateSettingsCache(false);
76
DBup = SchemaUpgradeWizard::Get("MusicDBSchemaVer",
77
currentDatabaseVersion);
79
// There may be a race condition where another frontend is upgrading,
80
// so wait up to 3 seconds for a more accurate version:
81
DBup->CompareAndWait(3);
83
if (DBup->versionsBehind == 0) // same schema
85
gContext->ActivateSettingsCache(true);
91
if (DBup->DBver.isEmpty())
93
retVal = doUpgradeMusicDatabaseSchema(DBup->DBver);
94
gContext->ActivateSettingsCache(true);
99
// Pop up messages, questions, warnings, et c.
100
switch (DBup->PromptForUpgrade("Music", true, false))
102
case MYTH_SCHEMA_USE_EXISTING:
103
gContext->ActivateSettingsCache(true);
105
case MYTH_SCHEMA_ERROR:
106
case MYTH_SCHEMA_EXIT:
108
case MYTH_SCHEMA_UPGRADE:
112
retVal = doUpgradeMusicDatabaseSchema(DBup->DBver);
113
gContext->ActivateSettingsCache(true);
118
static bool doUpgradeMusicDatabaseSchema(QString &dbver)
74
120
if (dbver.isEmpty())
76
122
VERBOSE(VB_IMPORTANT, "Inserting MythMusic initial database information.");