Bugzilla – Attachment 55502 Details for
Bug 17292
Use of DBIx in updatedatabase.pl broke upgrade (from bug 12375)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17292 - Use of DBIx in updatedatabase.pl broke upgrade
Bug-17292---Use-of-DBIx-in-updatedatabasepl-broke-.patch (text/plain), 3.77 KB, created by
Kyle M Hall (khall)
on 2016-09-12 15:19:44 UTC
(
hide
)
Description:
Bug 17292 - Use of DBIx in updatedatabase.pl broke upgrade
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-09-12 15:19:44 UTC
Size:
3.77 KB
patch
obsolete
>From f3bd7157279fabeefa7c82d417926f69a6ee3449 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 12 Sep 2016 14:20:19 +0000 >Subject: [PATCH] Bug 17292 - Use of DBIx in updatedatabase.pl broke upgrade > >A recent change in the 'subscription' table structure highlighted a >problem in a DBRev upgrade (3.23.00.006). As it adds a new column, when >upgrading from (say) 3.20.00.000 the code/schema (correctly) expects the >subscription.itemtype column to exist. But it is not created until DBRev >16.06.00.025. > >To reproduce: >- Have a clean 3.20.00 DB loaded into kohadevbox >- Checkout current master >- Run: > $ perl installer/data/mysql/updatedatabase.pl > => FAIL: The upgrade procedure fails due to missing colum. > > The solution: rewrite the updatedatabase.pl entry using plain DBI >--- > installer/data/mysql/updatedatabase.pl | 36 +++++++++++++++++++++------------- > 1 file changed, 22 insertions(+), 14 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 6ef6576..3670a2c 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -11469,13 +11469,19 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > ADD serialseq_z VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y > "); > >- my $schema = Koha::Database->new()->schema(); >- my @subscriptions = $schema->resultset('Subscription')->all(); >+ my $sth = $dbh->prepare("SELECT * FROM subscription"); >+ $sth->execute(); >+ >+ my $sth2 = $dbh->prepare("SELECT * FROM subscription_numberpatterns WHERE id = ?"); >+ >+ my $sth3 = $dbh->prepare("UPDATE serials SET serialseq_x = ?, serialseq_y = ?, serialseq_z = ? WHERE serialid = ?"); > >- foreach my $subscription (@subscriptions) { >+ foreach my $subscription ( $sth->fetchrow_hashref() ) { > my $number_pattern = $subscription->numberpattern(); >+ $sth2->execute( $subscription->{numberpattern} ); >+ my $number_pattern = $sth2->fetchrow_hashref(); > >- my $numbering_method = $number_pattern->numberingmethod(); >+ my $numbering_method = $number_pattern->{numberingmethod}; > # Get all the data between the enumeration values, we need > # to split each enumeration string based on these values. > my @splits = split( /\{[XYZ]\}/, $numbering_method ); >@@ -11487,12 +11493,15 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > } > my @indexes = sort { $indexes{$a} <=> $indexes{$b} } keys(%indexes); > >- my @serials = >- $schema->resultset('Serial') >- ->search( { subscriptionid => $subscription->subscriptionid() } ); >+ my @serials = @{ >+ $dbh->selectall_arrayref( >+ "SELECT * FROM serial WHERE subscriptionid = $subscription->{subscriptionid}", >+ { Slice => {} } >+ ) >+ }; > > foreach my $serial (@serials) { >- my $serialseq = $serial->serialseq(); >+ my $serialseq = $serial->{serialseq}; > my %enumeration_data; > > ## We cannot split on multiple values at once, >@@ -11514,12 +11523,11 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > $enumeration_data{ $indexes[0] } = $serialseq; > } > >- $serial->update( >- { >- serialseq_x => $enumeration_data{'X'}, >- serialseq_y => $enumeration_data{'Y'}, >- serialseq_z => $enumeration_data{'Z'}, >- } >+ $sth3->execute( >+ $enumeration_data{'X'}, >+ $enumeration_data{'Y'}, >+ $enumeration_data{'Z'}, >+ $serial->{serialid}, > ); > } > } >-- >2.1.4
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 17292
:
55502
|
55672
|
55673
|
55674
|
55861
|
55862
|
56734