Marcel de Rooy
fb41768d9f
MariaDB [koha_myclone]> update borrowers set updated_on=COALESCE( NULL, FROM_UNIXTIME(0) ) where borrowernumber=51; ERROR 1292 (22007): Incorrect datetime value: '1970-01-01 00:00:00' for column `koha_myclone`.`borrowers`.`updated_on` at row 1 MariaDB [koha_myclone]> update borrowers set updated_on=COALESCE( NULL, FROM_UNIXTIME(1) ) where borrowernumber=51; Query OK, 1 row affected (0.008 sec) Rows matched: 1 Changed: 1 Warnings: 0 Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Tested by switching updated_on to datetime. Remove NOT NULL, etc. Copied dbrev to atomicupdate folder. Resulted in: Updated all NULL values of borrowers.updated_on to GREATEST(date_renewed, dateenrolled, lastseen): 51 rows updated Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
46 lines
1.9 KiB
Perl
Executable file
46 lines
1.9 KiB
Perl
Executable file
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(1)),
|
|
COALESCE(dateenrolled, FROM_UNIXTIME(1)),
|
|
COALESCE(lastseen, FROM_UNIXTIME(1))
|
|
)
|
|
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(1)),
|
|
COALESCE(dateenrolled, FROM_UNIXTIME(1)),
|
|
COALESCE(lastseen, FROM_UNIXTIME(1))
|
|
)
|
|
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';
|
|
},
|
|
};
|