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 <
libmythbase/mythcorecontext.h
>
10
#include <
libmythbase/mythdb.h
>
11
#include <
libmythbase/mythdbcheck.h
>
12
#include <
libmythbase/mythlogging.h
>
13
14
// MythNews headers
15
#include "
newsdbcheck.h
"
16
17
const
QString
currentDatabaseVersion
=
"1001"
;
18
const
QString
MythNewsVersionName
=
"NewsDBSchemaVer"
;
19
20
bool
UpgradeNewsDatabaseSchema
(
void
)
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
};
41
if
(!
performActualUpdate
(
"MythNews"
,
MythNewsVersionName
,
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
53
if
(!
performActualUpdate
(
"MythNews"
,
MythNewsVersionName
,
54
updates,
"1001"
, dbver))
55
return
false
;
56
}
57
58
return
true
;
59
}
60
currentDatabaseVersion
const QString currentDatabaseVersion
Definition:
newsdbcheck.cpp:17
mythdb.h
newsdbcheck.h
MythNewsVersionName
const QString MythNewsVersionName
Definition:
newsdbcheck.cpp:18
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition:
mythlogging.h:39
mythlogging.h
UpgradeNewsDatabaseSchema
bool UpgradeNewsDatabaseSchema(void)
Definition:
newsdbcheck.cpp:20
mythdbcheck.h
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition:
mythcorecontext.cpp:57
performActualUpdate
bool performActualUpdate(const QString &component, const QString &versionkey, const DBUpdates &updates, const QString &version, QString &dbver)
Definition:
dbcheckcommon.cpp:113
mythcorecontext.h
DBUpdates
std::vector< std::string > DBUpdates
Definition:
mythdbcheck.h:9
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition:
mythcorecontext.cpp:904
Generated on Wed Feb 26 2025 03:17:52 for MythTV by
1.8.17