Skip to content

Commit

Permalink
2016-05-20 Fred Gleason <[email protected]>
Browse files Browse the repository at this point in the history
	* Removed the 'not null' attribute from the 'LOGS.LINK_DATETIME',
	'LOGS.START_DATE' and 'LOGS.END_DATE' fields in the database
	[GitHub issue #121].
	* Incremented the database version to 257.
  • Loading branch information
ElvishArtisan committed May 20, 2016
1 parent 5d0ee9c commit db9da6d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -15150,3 +15150,8 @@
2016-05-20 Fred Gleason <[email protected]>
* Fixed a bug in 'rdadmin/createdb.cpp' that caused creation
of a new DB to fail.
2016-05-20 Fred Gleason <[email protected]>
* 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.
2 changes: 1 addition & 1 deletion lib/dbversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/*
* Current Database Version
*/
#define RD_VERSION_DATABASE 256
#define RD_VERSION_DATABASE 257


#endif // DBVERSION_H
25 changes: 20 additions & 5 deletions rdadmin/createdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,\
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 ****

Expand Down
25 changes: 25 additions & 0 deletions utils/rdrevert/rdrevert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ void MainObject::Revert(int schema) const
case 256:
Revert256();
break;

case 257:
Revert257();
break;
}
}

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions utils/rdrevert/rdrevert.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit db9da6d

Please sign in to comment.