From a6abd7bc27129d85af483ca444cd210a11bb10ae Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Thu, 15 Jun 2023 12:13:45 +0000 Subject: [PATCH] Bug 26170: Database update Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- .../bug26170-protected-patrons.pl | 30 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 ++ 2 files changed, 32 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug26170-protected-patrons.pl diff --git a/installer/data/mysql/atomicupdate/bug26170-protected-patrons.pl b/installer/data/mysql/atomicupdate/bug26170-protected-patrons.pl new file mode 100755 index 00000000000..7b27bb13376 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug26170-protected-patrons.pl @@ -0,0 +1,30 @@ +use Modern::Perl; + +return { + bug_number => "26170", + description => "Create system patrons that cannot be (easily) deleted via the web UI", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + if ( !column_exists( 'borrowers', 'protected' ) ) { + $dbh->do( + q{ + ALTER TABLE borrowers ADD COLUMN protected tinyint(1) NOT NULL DEFAULT 0 + COMMENT 'boolean flag to mark selected patrons as protected from deletion' + AFTER `primary_contact_method`; + } + ); + } + say $out "Added column borrowers.protected"; + if ( !column_exists( 'deletedborrowers', 'protected' ) ) { + $dbh->do( + q{ + ALTER TABLE deletedborrowers ADD COLUMN protected tinyint(1) NOT NULL DEFAULT 0 + COMMENT 'boolean flag to mark selected patrons as protected from deletion' + AFTER `primary_contact_method`; + } + ); + } + say $out "Added column deletedborrowers.protected"; + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c99e69e2b7e..76f38aef487 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1559,6 +1559,7 @@ CREATE TABLE `borrowers` ( `anonymized` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'flag for data anonymization', `autorenew_checkouts` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'flag for allowing auto-renewal', `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes', + `protected` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to mark selected patrons as protected from deletion', PRIMARY KEY (`borrowernumber`), UNIQUE KEY `cardnumber` (`cardnumber`), UNIQUE KEY `userid` (`userid`), @@ -2688,6 +2689,7 @@ CREATE TABLE `deletedborrowers` ( `anonymized` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'flag for data anonymization', `autorenew_checkouts` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'flag for allowing auto-renewal', `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes', + `protected` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to mark selected patrons as protected from deletion', KEY `borrowernumber` (`borrowernumber`), KEY `cardnumber` (`cardnumber`), KEY `sms_provider_id` (`sms_provider_id`) -- 2.41.0