Bug 11165 - Save and update auth_header.modification_time
Summary: Save and update auth_header.modification_time
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-30 08:18 UTC by Fridolin Somers
Modified: 2015-12-03 22:11 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 11165: Automatically save the authority last modification time (1.51 KB, patch)
2014-12-11 15:54 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 11165: Automatically save the authority last modification time (2.34 KB, patch)
2015-03-19 09:40 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 11165: Automatically save the authority last modification time (2.32 KB, patch)
2015-03-19 09:40 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 11165: Automatically save the authority last modification time (2.68 KB, patch)
2015-03-19 12:49 UTC, Marcel de Rooy
Details | Diff | Splinter Review
[PASSED QA] Bug 11165: Automatically save the authority last modification time (2.82 KB, patch)
2015-04-17 10:37 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2013-10-30 08:18:14 UTC
In auth_header table has columns datecreated and datemodified.
Those columns are never filled by code.
Should they be managed by database ?
Comment 1 Jonathan Druart 2014-12-11 15:43:23 UTC
datecreated is set in C4::AuthoritiesMarc::AddAuthority:

 694     my $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode,marc,marcxml) values (?,now(),?,?,?)");
Comment 2 Jonathan Druart 2014-12-11 15:54:15 UTC Comment hidden (obsolete)
Comment 3 Marcel de Rooy 2015-03-19 08:55:21 UTC
What about:
Koha/Schema/Result/AuthHeader.pm:  "datemodified",
installer/data/mysql/kohastructure.sql:  `datemodified` date default NULL,

Also I do not like the update of datemodified when running the dbrev. If you rename the column and add the 'on update' clause later, you should be able to prevent that.
Comment 4 Jonathan Druart 2015-03-19 09:40:17 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2015-03-19 09:40:58 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2015-03-19 09:42:01 UTC
(In reply to M. de Rooy from comment #3)
> What about:
> Koha/Schema/Result/AuthHeader.pm:  "datemodified",
> installer/data/mysql/kohastructure.sql:  `datemodified` date default NULL,

Oops!
The schema file will be updated by the RM.

> Also I do not like the update of datemodified when running the dbrev. If you
> rename the column and add the 'on update' clause later, you should be able
> to prevent that.

Ho good catch, I have just tried and it seems to work!
Comment 7 Marcel de Rooy 2015-03-19 12:49:15 UTC Comment hidden (obsolete)
Comment 8 Kyle M Hall 2015-04-17 10:37:15 UTC
Created attachment 38026 [details] [review]
[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 <m.de.rooy@rijksmuseum.nl>
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 <kyle@bywatersolutions.com>
Comment 9 Tomás Cohen Arazi 2015-04-29 18:44:13 UTC
Patch pushed to master.

Thanks Jonathan!