From db9da6dc623bc754407dc6515b37c6d4854ab53d Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Fri, 20 May 2016 16:45:56 -0400 Subject: [PATCH] 2016-05-20 Fred Gleason * Removed the 'not null' attribute from the 'LOGS.LINK_DATETIME', 'LOGS.START_DATE' and 'LOGS.END_DATE' fields in the database [GitHub issue #000121]. * Incremented the database version to 257. --- ChangeLog | 5 +++++ lib/dbversion.h | 2 +- rdadmin/createdb.cpp | 25 ++++++++++++++++++++----- utils/rdrevert/rdrevert.cpp | 25 +++++++++++++++++++++++++ utils/rdrevert/rdrevert.h | 1 + 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1eba637fd..c89f8fc28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15150,3 +15150,8 @@ 2016-05-20 Fred Gleason * Fixed a bug in 'rdadmin/createdb.cpp' that caused creation of a new DB to fail. +2016-05-20 Fred Gleason + * Removed the 'not null' attribute from the 'LOGS.LINK_DATETIME', + 'LOGS.START_DATE' and 'LOGS.END_DATE' fields in the database + [GitHub issue #000121]. + * Incremented the database version to 257. diff --git a/lib/dbversion.h b/lib/dbversion.h index 8874593c1..f30135835 100644 --- a/lib/dbversion.h +++ b/lib/dbversion.h @@ -24,7 +24,7 @@ /* * Current Database Version */ -#define RD_VERSION_DATABASE 256 +#define RD_VERSION_DATABASE 257 #endif // DBVERSION_H diff --git a/rdadmin/createdb.cpp b/rdadmin/createdb.cpp index 64c64fb28..6eb6cb560 100644 --- a/rdadmin/createdb.cpp +++ b/rdadmin/createdb.cpp @@ -1197,11 +1197,11 @@ bool CreateDb(QString name,QString pwd) DESCRIPTION CHAR(64),\ ORIGIN_USER CHAR(255) NOT NULL,\ ORIGIN_DATETIME DATETIME NOT NULL,\ - LINK_DATETIME DATETIME NOT NULL,\ + LINK_DATETIME DATETIME,\ MODIFIED_DATETIME DATETIME NOT NULL,\ AUTO_REFRESH enum('N','Y') default 'N',\ - START_DATE DATE NOT NULL,\ - END_DATE DATE NOT NULL,\ + START_DATE DATE,\ + END_DATE DATE,\ PURGE_DATE date,\ IMPORT_DATE date,\ SCHEDULED_TRACKS int unsigned default 0,\ @@ -2627,8 +2627,9 @@ bool InitDb(QString name,QString pwd,QString station_name) if(!RunQuery(sql)) { return false; } - sql="insert into LOGS (NAME,SERVICE,DESCRIPTION,ORIGIN_USER,ORIGIN_DATETIME)\ - values (\"SAMPLE\",\"Production\",\"Sample Log\",\"user\",NOW())"; + sql=QString("insert into LOGS ")+ + "(NAME,SERVICE,DESCRIPTION,ORIGIN_USER,ORIGIN_DATETIME,MODIFIED_DATETIME) "+ + "values (\"SAMPLE\",\"Production\",\"Sample Log\",\"user\",now(),now())"; if(!RunQuery(sql)) { return false; } @@ -8222,6 +8223,20 @@ int UpdateDb(int ver) delete q; } + if(ver<257) { + sql=QString("alter table LOGS modify column LINK_DATETIME datetime"); + q=new QSqlQuery(sql); + delete q; + + sql=QString("alter table LOGS modify column START_DATE date"); + q=new QSqlQuery(sql); + delete q; + + sql=QString("alter table LOGS modify column END_DATE date"); + q=new QSqlQuery(sql); + delete q; + } + // **** End of version updates **** diff --git a/utils/rdrevert/rdrevert.cpp b/utils/rdrevert/rdrevert.cpp index f23c282e0..3a23472fd 100644 --- a/utils/rdrevert/rdrevert.cpp +++ b/utils/rdrevert/rdrevert.cpp @@ -171,6 +171,10 @@ void MainObject::Revert(int schema) const case 256: Revert256(); break; + + case 257: + Revert257(); + break; } } @@ -427,6 +431,27 @@ void MainObject::Revert256() const } +void MainObject::Revert257() const +{ + QString sql; + QSqlQuery *q; + + sql=QString("alter table LOGS modify column LINK_DATETIME datetime not null"); + q=new QSqlQuery(sql); + delete q; + + sql=QString("alter table LOGS modify column START_DATE date not null"); + q=new QSqlQuery(sql); + delete q; + + sql=QString("alter table LOGS modify column END_DATE date not null"); + q=new QSqlQuery(sql); + delete q; + + SetVersion(256); +} + + int MainObject::GetVersion() const { QString sql; diff --git a/utils/rdrevert/rdrevert.h b/utils/rdrevert/rdrevert.h index 0e4b73eb6..a4bd0ee2e 100644 --- a/utils/rdrevert/rdrevert.h +++ b/utils/rdrevert/rdrevert.h @@ -52,6 +52,7 @@ class MainObject : public QObject void Revert254() const; void Revert255() const; void Revert256() const; + void Revert257() const; int GetVersion() const; void SetVersion(int schema) const; int MapSchema(const QString &ver);