From ebe42e4c010d40d4eec42e5b87ea99b861df33ae Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Dec 2014 16:49:34 +0100 Subject: [PATCH] [PASSED QA] Bug 11165: Automatically save the authority last modification time This patch rename the column auth_header.datemodified with modification_time. Now this column will be automatically updated when a row will be updated. Test plan: 0/ Verify that la major part of your auth_header.datemodified is set to null 1/ Execute the updatedb entry 2/ Verify that the column is renamed and the values have not been changed. 3/ Update an authority and verify (using the sql cli) that this value has been updated. Signed-off-by: Marcel de Rooy In the absence of a coding guideline stipulating a preferred column name for a timestamp, this modification_time works for me. Null values are replaced by current time after db rev; other values are left alone. NOTE FOR RM: Please run update_dbix_class_files.pl. Signed-off-by: Kyle M Hall --- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a74d81a..b1e9270 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -24,7 +24,7 @@ CREATE TABLE `auth_header` ( `authid` bigint(20) unsigned NOT NULL auto_increment, `authtypecode` varchar(10) NOT NULL default '', `datecreated` date default NULL, - `datemodified` date default NULL, + `modification_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `origincode` varchar(20) default NULL, `authtrees` mediumtext, `marc` blob, diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index ca27cde..b08766a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -10035,6 +10035,20 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.19.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q| + ALTER TABLE auth_header + CHANGE COLUMN datemodified modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP + |); + $dbh->do(q| + ALTER TABLE auth_header + CHANGE COLUMN modification_time modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP + |); + print "Upgrade to $DBversion done (Bug 11165: Update auth_header.datemodified when updated)\n"; + SetVersion ($DBversion); +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 1.7.2.5