From 991b549c9c9f3c27d62ccf4ba4fefedcf9279a0a 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 Signed-off-by: Andrew Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Katrin Fischer --- .../bug_24476_opt_out_of_auto_renewal.perl | 21 +++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 3 +++ 2 files changed, 24 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..9bc691bd9b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24476_opt_out_of_auto_renewal.perl @@ -0,0 +1,21 @@ +$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" ); + } + unless( column_exists('borrower_modifications','autorenewal') ){ + $dbh->do( "ALTER TABLE borrower_modifications 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 6495f25bbd..28638ed6a4 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -589,6 +589,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`) @@ -1530,6 +1531,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`), @@ -3437,6 +3439,7 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` ( `privacy` int(11) DEFAULT NULL, `extended_attributes` MEDIUMTEXT DEFAULT NULL, `gdpr_proc_consent` datetime, -- data processing consent + `autorenewal` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal PRIMARY KEY (`verification_token` (191),`borrowernumber`), KEY `verification_token` (`verification_token` (191)), KEY `borrowernumber` (`borrowernumber`) -- 2.11.0