Bugzilla – Attachment 123363 Details for
Bug 25078
Update DB process - wrap each DBRev inside a transaction and better error handling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25078: Move DB revs up to 21.06.00.011
Bug-25078-Move-DB-revs-up-to-210600011.patch (text/plain), 13.11 KB, created by
Jonathan Druart
on 2021-08-02 10:30:00 UTC
(
hide
)
Description:
Bug 25078: Move DB revs up to 21.06.00.011
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-08-02 10:30:00 UTC
Size:
13.11 KB
patch
obsolete
>From ad3a06a838981f414ecfc9167c40bcc7d63690d6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25078
:
102521
|
116032
|
116033
|
116034
|
116208
|
116209
|
117084
|
121909
|
121910
|
121911
|
121982
|
121983
|
121984
|
122208
|
122322
|
122323
|
122324
|
122325
|
122326
|
122329
|
122665
|
122666
|
122667
|
122668
|
122669
|
122670
|
122671
|
122679
|
122680
|
122875
|
123356
|
123357
|
123358
|
123359
|
123360
|
123361
|
123362
| 123363 |
123364
|
123365
|
123366
|
123367
|
123850
|
123851
|
123853
|
123937
|
124269