From a63aec651e9e1e9ca9c550229e1acfea4224dd4c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 23 Jan 2020 02:35:38 +0000 Subject: [PATCH] Bug 24476: Database updates --- .../bug_24476_opt_out_of_auto_renewal.perl | 18 ++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_24476_opt_out_of_auto_renewal.perl diff --git a/installer/data/mysql/atomicupdate/bug_24476_opt_out_of_auto_renewal.perl b/installer/data/mysql/atomicupdate/bug_24476_opt_out_of_auto_renewal.perl new file mode 100644 index 0000000000..c06a2a876f --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24476_opt_out_of_auto_renewal.perl @@ -0,0 +1,18 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( column_exists('borrowers','autorenewal') ){ + $dbh->do( "ALTER TABLE borrowers ADD COLUMN autorenewal TINYINT(1) NOT NULL DEFAULT 1" ); + } + unless( column_exists('deletedborrowers','autorenewal') ){ + $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenewal TINYINT(1) NOT NULL DEFAULT 1" ); + } + $dbh->do(q{ + UPDATE systempreferences + SET value = CONCAT(value,'|autorenewal') + WHERE variable IN + ('PatronSelfModificationBorrowerUnwantedField','PatronSelfRegistrationBorrowerUnwantedField') + AND value NOT LIKE '%autorenewal%' + }); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24476 - Allow patrons to opt-out of autorenewal)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3f28188c02..7a29b9bfa8 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -590,6 +590,7 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower `login_attempts` int(4) default 0, -- number of failed login attemps `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization + `autorenewal` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal KEY borrowernumber (borrowernumber), KEY `cardnumber` (`cardnumber`), KEY `sms_provider_id` (`sms_provider_id`) @@ -1585,6 +1586,7 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons `login_attempts` int(4) default 0, -- number of failed login attemps `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization + `autorenewal` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal UNIQUE KEY `cardnumber` (`cardnumber`), PRIMARY KEY `borrowernumber` (`borrowernumber`), KEY `categorycode` (`categorycode`), -- 2.11.0