Bug 26170: Database update

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Magnus Enger 2023-06-15 12:13:45 +00:00 committed by Tomas Cohen Arazi
parent 8194419144
commit 965797092e
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 32 additions and 0 deletions

View file

@ -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";
},
};

View file

@ -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`),
@ -2690,6 +2691,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`)