MythTV master
newsdbcheck.cpp
Go to the documentation of this file.
1// C++ headers
2#include <iostream>
3
4// QT headers
5#include <QSqlError>
6#include <QString>
7
8// Myth headers
10#include <libmythbase/mythdb.h>
13
14// MythNews headers
15#include "newsdbcheck.h"
16
17const QString currentDatabaseVersion = "1001";
18const QString MythNewsVersionName = "NewsDBSchemaVer";
19
21{
22 QString dbver = gCoreContext->GetSetting("NewsDBSchemaVer");
23
24 if (dbver == currentDatabaseVersion)
25 return true;
26
27 if (dbver.isEmpty())
28 {
29 LOG(VB_GENERAL, LOG_NOTICE,
30 "Inserting MythNews initial database information.");
31
32 DBUpdates updates
33 {
34 "CREATE TABLE IF NOT EXISTS newssites "
35 "( name VARCHAR(100) NOT NULL PRIMARY KEY,"
36 " category VARCHAR(255) NOT NULL,"
37 " url VARCHAR(255) NOT NULL,"
38 " ico VARCHAR(255),"
39 " updated INT UNSIGNED);"
40 };
42 updates, "1000", dbver))
43 return false;
44 }
45
46 if (dbver == "1000")
47 {
48 DBUpdates updates
49 {
50 "ALTER TABLE `newssites` ADD `podcast` BOOL NOT NULL DEFAULT '0';"
51 };
52
54 updates, "1001", dbver))
55 return false;
56 }
57
58 return true;
59}
60
QString GetSetting(const QString &key, const QString &defaultval="")
bool performActualUpdate(const QString &component, const QString &versionkey, const DBUpdates &updates, const QString &version, QString &dbver)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
std::vector< std::string > DBUpdates
Definition: mythdbcheck.h:9
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
const QString currentDatabaseVersion
Definition: newsdbcheck.cpp:17
const QString MythNewsVersionName
Definition: newsdbcheck.cpp:18
bool UpgradeNewsDatabaseSchema(void)
Definition: newsdbcheck.cpp:20