Skip to content

Commit

Permalink
Update internetcontent* to use datetime, not timestamp.
Browse files Browse the repository at this point in the history
We don't need timestamp types for these columns, so use the more-robust
datetime type for the tables (a type that won't be broken by invalid
backup/restore approaches).
  • Loading branch information
sphery committed May 23, 2011
1 parent 78834bc commit 032e2cb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mythtv/bindings/perl/MythTV.pm
Expand Up @@ -114,7 +114,7 @@ package MythTV;
# schema version supported in the main code. We need to check that the schema
# version in the database is as expected by the bindings, which are expected
# to be kept in sync with the main code.
our $SCHEMA_VERSION = "1273";
our $SCHEMA_VERSION = "1274";

# NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
# the number of items in a ProgramInfo QStringList group used by
Expand Down
2 changes: 1 addition & 1 deletion mythtv/bindings/python/MythTV/static.py
Expand Up @@ -5,7 +5,7 @@
"""

OWN_VERSION = (0,25,-1,2)
SCHEMA_VERSION = 1273
SCHEMA_VERSION = 1274
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
PROTO_VERSION = '65'
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmyth/netutils.cpp
Expand Up @@ -258,10 +258,10 @@ bool insertGrabberInDB(const QString &name, const QString &thumbnail,

MSqlQuery query(MSqlQuery::InitCon());
query.prepare("INSERT INTO internetcontent (name,thumbnail,type,author,"
"description,commandline,version,updated,search,tree,podcast,"
"description,commandline,version,search,tree,podcast,"
"host) "
"VALUES( :NAME, :THUMBNAIL, :TYPE, :AUTHOR, :DESCRIPTION, :COMMAND, "
":VERSION, :UPDATED, :SEARCH, :TREE, :PODCAST, :HOST);");
":VERSION, :SEARCH, :TREE, :PODCAST, :HOST);");
query.bindValue(":NAME", name);
query.bindValue(":THUMBNAIL", thumbbase);
query.bindValue(":TYPE", type);
Expand All @@ -270,7 +270,6 @@ bool insertGrabberInDB(const QString &name, const QString &thumbnail,
QFileInfo cmd(commandline);
query.bindValue(":COMMAND", cmd.fileName());
query.bindValue(":VERSION", version);
query.bindValue(":UPDATED", QDateTime());
query.bindValue(":SEARCH", search);
query.bindValue(":TREE", tree);
query.bindValue(":PODCAST", podcast);
Expand Down
6 changes: 5 additions & 1 deletion mythtv/libs/libmyth/rssparse.cpp
Expand Up @@ -35,7 +35,10 @@ ResultItem::ResultItem(const QString& title, const QString& subtitle,
m_thumbnail = thumbnail;
m_mediaURL = mediaURL;
m_author = author;
m_date = date;
if (!date.isNull())
m_date = date;
else
m_date = QDateTime::fromString("0000-00-00T00:00:00", Qt::ISODate);
m_time = time;
m_rating = rating;
m_filesize = filesize;
Expand All @@ -55,6 +58,7 @@ ResultItem::ResultItem(const QString& title, const QString& subtitle,

ResultItem::ResultItem()
{
m_date = QDateTime::fromString("0000-00-00T00:00:00", Qt::ISODate);
}

ResultItem::~ResultItem()
Expand Down
21 changes: 16 additions & 5 deletions mythtv/libs/libmythtv/dbcheck.cpp
Expand Up @@ -21,7 +21,7 @@ using namespace std;
mythtv/bindings/perl/MythTV.pm
*/
/// This is the DB schema version expected by the running MythTV instance.
const QString currentDatabaseVersion = "1273";
const QString currentDatabaseVersion = "1274";

static bool UpdateDBVersionNumber(const QString &newnumber, QString &dbver);
static bool performActualUpdate(
Expand Down Expand Up @@ -5219,8 +5219,7 @@ NULL
" description TEXT NOT NULL,"
" commandline TEXT NOT NULL,"
" version DOUBLE NOT NULL,"
" updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP "
" ON UPDATE CURRENT_TIMESTAMP,"
" updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"
" search BOOL NOT NULL,"
" tree BOOL NOT NULL,"
" podcast BOOL NOT NULL,"
Expand All @@ -5240,8 +5239,7 @@ NULL
" thumbnail TEXT NOT NULL,"
" mediaURL TEXT NOT NULL,"
" author VARCHAR(255) NOT NULL,"
" date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP "
" ON UPDATE CURRENT_TIMESTAMP,"
" date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"
" time INT NOT NULL,"
" rating VARCHAR(255) NOT NULL,"
" filesize BIGINT NOT NULL,"
Expand Down Expand Up @@ -5648,6 +5646,19 @@ NULL
return false;
}

if (dbver == "1273")
{
const char *updates[] = {
"ALTER TABLE internetcontent MODIFY COLUMN updated "
" DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';",
"ALTER TABLE internetcontentarticles MODIFY COLUMN `date` "
" DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';",
NULL
};
if (!performActualUpdate(updates, "1274", dbver))
return false;
}

return true;
}

Expand Down

0 comments on commit 032e2cb

Please sign in to comment.