5 description => "Fix definition of borrowers.updated_on and deletedborrowers.updated_on",
8 my ($dbh, $out) = @$args{qw(dbh out)};
12 SET updated_on = GREATEST(
13 COALESCE(date_renewed, FROM_UNIXTIME(1)),
14 COALESCE(dateenrolled, FROM_UNIXTIME(1)),
15 COALESCE(lastseen, FROM_UNIXTIME(1))
17 WHERE updated_on IS NULL
19 say $out sprintf('Updated all NULL values of borrowers.updated_on to GREATEST(date_renewed, dateenrolled, lastseen): %d rows updated', $rv);
22 UPDATE deletedborrowers
23 SET updated_on = GREATEST(
24 COALESCE(date_renewed, FROM_UNIXTIME(1)),
25 COALESCE(dateenrolled, FROM_UNIXTIME(1)),
26 COALESCE(lastseen, FROM_UNIXTIME(1))
28 WHERE updated_on IS NULL
30 say $out sprintf('Updated all NULL values of borrowers.updated_on to GREATEST(date_renewed, dateenrolled, lastseen): %d rows updated', $rv);
34 MODIFY updated_on timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
35 COMMENT 'time of last change could be useful for synchronization with external systems (among others)'
37 say $out 'Fixed definition of borrowers.updated_on';
40 ALTER TABLE deletedborrowers
41 MODIFY updated_on timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
42 COMMENT 'time of last change could be useful for synchronization with external systems (among others)'
44 say $out 'Fixed definition of deletedborrowers.updated_on';