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
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
(cherry picked from commit f11f07a703)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
parent
3c2bd4ef3b
commit
fc42eeba6a
|
|
@ -11466,13 +11466,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();
|
||||
|
||||
foreach my $subscription (@subscriptions) {
|
||||
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 ( $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 );
|
||||
|
|
@ -11484,12 +11490,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,
|
||||
|
|
@ -11511,12 +11520,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},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue