MythTV
master
mythplugins
mythnews
mythnews
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
9
#include <
libmyth/mythcontext.h
>
10
#include <
libmythbase/mythdb.h
>
11
#include <
libmythbase/mythdbcheck.h
>
12
13
// MythNews headers
14
#include "
newsdbcheck.h
"
15
16
const
QString
currentDatabaseVersion
=
"1001"
;
17
const
QString
MythNewsVersionName
=
"NewsDBSchemaVer"
;
18
19
bool
UpgradeNewsDatabaseSchema
(
void
)
20
{
21
QString dbver =
gCoreContext
->
GetSetting
(
"NewsDBSchemaVer"
);
22
23
if
(dbver ==
currentDatabaseVersion
)
24
return
true
;
25
26
if
(dbver.isEmpty())
27
{
28
LOG
(VB_GENERAL, LOG_NOTICE,
29
"Inserting MythNews initial database information."
);
30
31
DBUpdates
updates
32
{
33
"CREATE TABLE IF NOT EXISTS newssites "
34
"( name VARCHAR(100) NOT NULL PRIMARY KEY,"
35
" category VARCHAR(255) NOT NULL,"
36
" url VARCHAR(255) NOT NULL,"
37
" ico VARCHAR(255),"
38
" updated INT UNSIGNED);"
39
};
40
if
(!
performActualUpdate
(
"MythNews"
,
MythNewsVersionName
,
41
updates,
"1000"
, dbver))
42
return
false
;
43
}
44
45
if
(dbver ==
"1000"
)
46
{
47
DBUpdates
updates
48
{
49
"ALTER TABLE `newssites` ADD `podcast` BOOL NOT NULL DEFAULT '0';"
50
};
51
52
if
(!
performActualUpdate
(
"MythNews"
,
MythNewsVersionName
,
53
updates,
"1001"
, dbver))
54
return
false
;
55
}
56
57
return
true
;
58
}
59
currentDatabaseVersion
const QString currentDatabaseVersion
Definition:
newsdbcheck.cpp:16
mythdb.h
newsdbcheck.h
MythNewsVersionName
const QString MythNewsVersionName
Definition:
newsdbcheck.cpp:17
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition:
mythlogging.h:39
UpgradeNewsDatabaseSchema
bool UpgradeNewsDatabaseSchema(void)
Definition:
newsdbcheck.cpp:19
mythdbcheck.h
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition:
mythcorecontext.cpp:55
performActualUpdate
bool performActualUpdate(const QString &component, const QString &versionkey, const DBUpdates &updates, const QString &version, QString &dbver)
Definition:
dbcheckcommon.cpp:113
mythcontext.h
DBUpdates
std::vector< std::string > DBUpdates
Definition:
mythdbcheck.h:9
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition:
mythcorecontext.cpp:902
Generated on Tue Feb 18 2025 03:17:01 for MythTV by
1.8.17