From ad3a06a838981f414ecfc9167c40bcc7d63690d6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 8 Jul 2021 09:43:58 +0200 Subject: [PATCH] Bug 25078: Move DB revs up to 21.06.00.011 Updated on 2021-08-02 for 21.06.00.011 --- installer/data/mysql/db_revs/210600001.pl | 13 ++ installer/data/mysql/db_revs/210600002.pl | 28 ++++ installer/data/mysql/db_revs/210600003.pl | 33 ++++ installer/data/mysql/db_revs/210600004.pl | 21 +++ installer/data/mysql/db_revs/210600005.pl | 15 ++ installer/data/mysql/updatedatabase.pl | 195 ---------------------- 6 files changed, 110 insertions(+), 195 deletions(-) create mode 100644 installer/data/mysql/db_revs/210600001.pl create mode 100644 installer/data/mysql/db_revs/210600002.pl create mode 100644 installer/data/mysql/db_revs/210600003.pl create mode 100644 installer/data/mysql/db_revs/210600004.pl create mode 100644 installer/data/mysql/db_revs/210600005.pl diff --git a/installer/data/mysql/db_revs/210600001.pl b/installer/data/mysql/db_revs/210600001.pl new file mode 100644 index 00000000000..ee84b39907e --- /dev/null +++ b/installer/data/mysql/db_revs/210600001.pl @@ -0,0 +1,13 @@ +use Modern::Perl; + +{ + bug_number => "28489", + description => "Modify sessions.a_session from longtext to longblob", + up => sub { + my ($args) = @_; + my $dbh = $args->{dbh}; + + $dbh->do('DELETE FROM sessions'); + $dbh->do('ALTER TABLE sessions MODIFY a_session LONGBLOB NOT NULL'); + }, +} diff --git a/installer/data/mysql/db_revs/210600002.pl b/installer/data/mysql/db_revs/210600002.pl new file mode 100644 index 00000000000..25e0f6d9e7b --- /dev/null +++ b/installer/data/mysql/db_revs/210600002.pl @@ -0,0 +1,28 @@ +use Modern::Perl; + +{ + bug_number => "28490", + description => "Bring back accidentally deleted relationship columns", + up => sub { + my ($args) = @_; + my $dbh = $args->{dbh}; + + if( !column_exists( 'borrower_modifications', 'relationship' ) ) { + $dbh->do(q{ + ALTER TABLE borrower_modifications ADD COLUMN `relationship` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL AFTER `borrowernotes` + }); + } + + if( !column_exists( 'borrowers', 'relationship' ) ) { + $dbh->do(q{ + ALTER TABLE borrowers ADD COLUMN `relationship` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'used for children to include the relationship to their guarantor' AFTER `borrowernotes` + }); + } + + if( !column_exists( 'deletedborrowers', 'relationship' ) ) { + $dbh->do(q{ + ALTER TABLE deletedborrowers ADD COLUMN `relationship` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'used for children to include the relationship to their guarantor' AFTER `borrowernotes` + }); + } + }, +} diff --git a/installer/data/mysql/db_revs/210600003.pl b/installer/data/mysql/db_revs/210600003.pl new file mode 100644 index 00000000000..edaa5807378 --- /dev/null +++ b/installer/data/mysql/db_revs/210600003.pl @@ -0,0 +1,33 @@ +use Modern::Perl; + +{ + bug_number => "24434", + description => "Add 'WrongTransfer' to branchtransfers.cancellation_reason enum", + up => sub { + my ($args) = @_; + my $dbh = $args->{dbh}; + + # add 'wrongtransfer' to branchtransfers cancellation_reason enum + $dbh->do( + q{ + alter table + `branchtransfers` + modify column + `cancellation_reason` enum( + 'manual', + 'stockrotationadvance', + 'stockrotationrepatriation', + 'returntohome', + 'returntoholding', + 'rotatingcollection', + 'reserve', + 'lostreserve', + 'cancelreserve', + 'itemlost', + 'wrongtransfer' + ) + after `comments` + } + ); + }, +} diff --git a/installer/data/mysql/db_revs/210600004.pl b/installer/data/mysql/db_revs/210600004.pl new file mode 100644 index 00000000000..e8a08841f04 --- /dev/null +++ b/installer/data/mysql/db_revs/210600004.pl @@ -0,0 +1,21 @@ +use Modern::Perl; + +{ + bug_number => "15788", + description => "Split edit_borrowers permission", + up => sub { + my ($args) = @_; + my $dbh = $args->{dbh}; + + $dbh->do(q{ + INSERT IGNORE permissions (module_bit, code, description) + VALUES + (4, 'delete_borrowers', 'Delete borrowers') + }); + + $dbh->do(q{ + INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) + SELECT borrowernumber, 4, 'delete_borrowers' FROM user_permissions WHERE code = 'edit_borrowers' + }); + }, +} diff --git a/installer/data/mysql/db_revs/210600005.pl b/installer/data/mysql/db_revs/210600005.pl new file mode 100644 index 00000000000..8386af88780 --- /dev/null +++ b/installer/data/mysql/db_revs/210600005.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +{ + bug_number => "26205", + description => "Add new system preference NewsLog to log news changes", + up => sub { + my ($args) = @_; + my $dbh = $args->{dbh}; + + $dbh->do( q{ + INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) + VALUES ('NewsLog', '0', 'If enabled, log OPAC News changes', '', 'YesNo') + }); + }, +} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f33d86fb94e..e9f2a538c20 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -24296,201 +24296,6 @@ unless ( $ENV{HTTP_HOST} ) { # Is that correct? } } -$DBversion = '21.06.00.001'; -if ( CheckVersion($DBversion) ) { - $dbh->do('DELETE FROM sessions'); - $dbh->do('ALTER TABLE sessions MODIFY a_session LONGBLOB NOT NULL'); - - NewVersion( $DBversion, '28489', 'Modify sessions.a_session from longtext to longblob' ); -} - -$DBversion = '21.06.00.002'; -if( CheckVersion( $DBversion ) ) { - if( !column_exists( 'borrower_modifications', 'relationship' ) ) { - $dbh->do(q{ - ALTER TABLE borrower_modifications ADD COLUMN `relationship` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL AFTER `borrowernotes` - }); - } - - if( !column_exists( 'borrowers', 'relationship' ) ) { - $dbh->do(q{ - ALTER TABLE borrowers ADD COLUMN `relationship` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'used for children to include the relationship to their guarantor' AFTER `borrowernotes` - }); - } - - if( !column_exists( 'deletedborrowers', 'relationship' ) ) { - $dbh->do(q{ - ALTER TABLE deletedborrowers ADD COLUMN `relationship` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'used for children to include the relationship to their guarantor' AFTER `borrowernotes` - }); - } - - NewVersion( $DBversion, 28490, "Bring back accidentally deleted relationship columns"); -} - -$DBversion = '21.06.00.003'; -if( CheckVersion( $DBversion ) ) { - - # Add 'WrongTransfer' to branchtransfers cancellation_reason enum - $dbh->do( - q{ - ALTER TABLE - `branchtransfers` - MODIFY COLUMN - `cancellation_reason` enum( - 'Manual', - 'StockrotationAdvance', - 'StockrotationRepatriation', - 'ReturnToHome', - 'ReturnToHolding', - 'RotatingCollection', - 'Reserve', - 'LostReserve', - 'CancelReserve', - 'ItemLost', - 'WrongTransfer' - ) - AFTER `comments` - } - ); - - NewVersion( $DBversion, 24434, "Add 'WrongTransfer' to branchtransfers.cancellation_reason enum"); -} - -$DBversion = '21.06.00.004'; -if ( CheckVersion($DBversion) ) { - - $dbh->do(q{ - INSERT IGNORE permissions (module_bit, code, description) - VALUES - (4, 'delete_borrowers', 'Delete borrowers') - }); - - $dbh->do(q{ - INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) - SELECT borrowernumber, 4, 'delete_borrowers' FROM user_permissions WHERE code = 'edit_borrowers' - }); - - NewVersion( $DBversion, 15788, "Split edit_borrowers permission" ); -} - -$DBversion = '21.06.00.005'; -if( CheckVersion( $DBversion ) ) { - $dbh->do( q{ - INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) - VALUES ('NewsLog', '0', 'If enabled, log OPAC News changes', '', 'YesNo') - }); - - NewVersion( $DBversion, 26205, "Add new system preference NewsLog to log news changes"); -} - -$DBversion = '21.06.00.006'; -if( CheckVersion( $DBversion ) ){ - unless( column_exists( 'course_items', 'biblionumber') ) { - $dbh->do(q{ ALTER TABLE course_items ADD `biblionumber` int(11) AFTER `itemnumber` }); - - $dbh->do(q{ - UPDATE course_items - LEFT JOIN items ON items.itemnumber=course_items.itemnumber - SET course_items.biblionumber=items.biblionumber - WHERE items.itemnumber IS NOT NULL - }); - - $dbh->do(q{ ALTER TABLE course_items MODIFY COLUMN `biblionumber` INT(11) NOT NULL }); - - $dbh->do(q{ ALTER TABLE course_items ADD CONSTRAINT `fk_course_items_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE }); - $dbh->do(q{ ALTER TABLE course_items CHANGE `itemnumber` `itemnumber` int(11) DEFAULT NULL }); - } - - NewVersion( $DBversion, 14237, ["Add course_items.biblionumber column", "Add fk_course_items_biblionumber constraint", "Change course_items.itemnumber to allow NULL values"] ); -} - -$DBversion = '21.06.00.007'; -if( CheckVersion( $DBversion ) ) { - if( !column_exists( 'borrowers', 'primary_contact_method' ) ) { - $dbh->do( "ALTER TABLE `borrowers` ADD COLUMN `primary_contact_method` VARCHAR(45) DEFAULT NULL AFTER `autorenew_checkouts`" ); - } - - if( !column_exists( 'deletedborrowers', 'primary_contact_method' ) ) { - $dbh->do( "ALTER TABLE `deletedborrowers` ADD COLUMN `primary_contact_method` VARCHAR(45) DEFAULT NULL AFTER `autorenew_checkouts`" ); - } - - if( !column_exists( 'borrower_modifications', 'primary_contact_method' ) ) { - $dbh->do( "ALTER TABLE `borrower_modifications` ADD COLUMN `primary_contact_method` VARCHAR(45) DEFAULT NULL AFTER `gdpr_proc_consent`" ); - } - - NewVersion( $DBversion, 11879, "Add a new field to patron record: main contact method"); -} - -$DBversion = '21.06.00.008'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ - INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES - ('ArticleRequestsOpacHostRedirection', '0', NULL, 'Enables redirection from child to host when requesting article on OPAC', 'YesNo') - }); - NewVersion( $DBversion, 20310, "Add pref ArticleRequestsOpacHostRedirection"); -} - -$DBversion = '21.06.00.009'; -if( CheckVersion( $DBversion ) ) { - unless ( column_exists('article_requests', 'format') ) { - $dbh->do(q| - ALTER TABLE article_requests - ADD COLUMN `format` enum('PHOTOCOPY', 'SCAN') NOT NULL DEFAULT 'PHOTOCOPY' AFTER notes - |); - } - unless ( column_exists('article_requests', 'urls') ) { - $dbh->do(q| - ALTER TABLE article_requests - ADD COLUMN `urls` MEDIUMTEXT AFTER format - |); - } - NewVersion( $DBversion, 20472, "Add columns format and urls in article_requests table"); -} - -$DBversion = '21.06.00.010'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ - INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES - ('ArticleRequestsSupportedFormats', 'PHOTOCOPY', 'PHOTOCOPY|SCAN', 'List supported formats between vertical bars', 'free') - }); - NewVersion( $DBversion, 20472, "Add syspref ArticleRequestsSupportedFormats"); -} - -$DBversion = '21.06.00.011'; -if( CheckVersion( $DBversion ) ) { - - my @fields = qw( - branchname - branchaddress1 - branchaddress2 - branchaddress3 - branchzip - branchcity - branchstate - branchcountry - branchphone - branchfax - branchemail - branchillemail - branchreplyto - branchreturnpath - branchurl - branchip - branchnotes - opac_info - marcorgcode - ); - for my $f ( @fields ) { - $dbh->do(qq{ - UPDATE branches - SET $f = NULL - WHERE $f = "" - }); - } - - NewVersion( $DBversion, 28567, "Set to NULL empty branches fields"); -} - # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.20.1