From 41786673c9d27cc64b6d6d54add59756b7183743 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 14 Mar 2022 14:21:14 +0000 Subject: [PATCH] Bug 23486: Set lastseen to default to current timestamp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generally, a patron is not registered without some action from the patron Defaulting the lastseen upon creation seems a reasonable way to set the initial value TO test: Apply patches Update database Create a patron Check their lastseen date Signed-off-by: Séverine QUEUNE --- .../bug_23486_set_lastseen_default.pl | 15 +++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_23486_set_lastseen_default.pl diff --git a/installer/data/mysql/atomicupdate/bug_23486_set_lastseen_default.pl b/installer/data/mysql/atomicupdate/bug_23486_set_lastseen_default.pl new file mode 100755 index 0000000000..3fc3617e4d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23486_set_lastseen_default.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => "23486", + description => "Default lastseen to current timestamp", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + ALTER TABLE borrowers CHANGE lastseen + lastseen datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'last time a patron has been seen (connected at the OPAC or staff interface)' + }); + say $out "Update lastseen colum to default to current timestamp"; + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 852d448804..ee0876dbb0 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1458,7 +1458,7 @@ CREATE TABLE `borrowers` ( `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'controls if relatives can see this patron''s checkouts', `checkprevcheckout` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.', `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)', - `lastseen` datetime DEFAULT NULL COMMENT 'last time a patron has been seen (connected at the OPAC or staff interface)', + `lastseen` datetime DEFAULT current_timestamp() COMMENT 'last time a patron has been seen (connected at the OPAC or staff interface)', `lang` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'lang to use to send notices to this patron', `login_attempts` int(4) NOT NULL DEFAULT 0 COMMENT 'number of failed login attemps', `overdrive_auth_token` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'persist OverDrive auth token', -- 2.30.2