@@ -, +, @@ deletedborrowers can do that by either: a) do a fresh install of Koha 16.05 and update to master, or b) execute the following SQL queries: ALTER TABLE borrowers MODIFY updated_on timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'time of last change could be useful for synchronization with external systems (among others)' ALTER TABLE deletedborrowers MODIFY updated_on timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'time of last change could be useful for synchronization with external systems (among others)' following SQL query: UPDATE borrowers SET updated_on = NULL WHERE borrowernumber = UPDATE deletedborrowers SET updated_on = NULL WHERE borrowernumber = not NULL-able. Verify that updated_on for X and Y have taken the value of dateenrolled. its account in order to set the columns borrowers.date_renewed and borrowers.lastseen before executing updatedatabase borrowers.updated_on should take the greatest value among dateenrolled, date_renewed, and lastseen --- .../data/mysql/atomicupdate/bug-27253.pl | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug-27253.pl --- a/installer/data/mysql/atomicupdate/bug-27253.pl +++ a/installer/data/mysql/atomicupdate/bug-27253.pl @@ -0,0 +1,46 @@ +use Modern::Perl; + +return { + bug_number => "27253", + description => "Fix definition of borrowers.updated_on and deletedborrowers.updated_on", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + my $rv = $dbh->do(q{ + UPDATE borrowers + SET updated_on = GREATEST( + COALESCE(date_renewed, FROM_UNIXTIME(0)), + COALESCE(dateenrolled, FROM_UNIXTIME(0)), + COALESCE(lastseen, FROM_UNIXTIME(0)) + ) + WHERE updated_on IS NULL + }); + say $out sprintf('Updated all NULL values of borrowers.updated_on to GREATEST(date_renewed, dateenrolled, lastseen): %d rows updated', $rv); + + $rv = $dbh->do(q{ + UPDATE deletedborrowers + SET updated_on = GREATEST( + COALESCE(date_renewed, FROM_UNIXTIME(0)), + COALESCE(dateenrolled, FROM_UNIXTIME(0)), + COALESCE(lastseen, FROM_UNIXTIME(0)) + ) + WHERE updated_on IS NULL + }); + say $out sprintf('Updated all NULL values of borrowers.updated_on to GREATEST(date_renewed, dateenrolled, lastseen): %d rows updated', $rv); + + $dbh->do(q{ + ALTER TABLE borrowers + MODIFY updated_on timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() + COMMENT 'time of last change could be useful for synchronization with external systems (among others)' + }); + say $out 'Fixed definition of borrowers.updated_on'; + + $dbh->do(q{ + ALTER TABLE deletedborrowers + MODIFY updated_on timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() + COMMENT 'time of last change could be useful for synchronization with external systems (among others)' + }); + say $out 'Fixed definition of deletedborrowers.updated_on'; + }, +}; --