|
Line 0
Link Here
|
| 0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
use Koha::Installer::Output qw(say_warning say_success say_info); |
| 3 |
|
| 4 |
return { |
| 5 |
bug_number => "26993", |
| 6 |
description => "Remove unique constraint on itemnumber in items_last_borrower to allow multiple borrowers per item", |
| 7 |
up => sub { |
| 8 |
my ($args) = @_; |
| 9 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
| 10 |
|
| 11 |
# Drop the foreign key constraint temporarily |
| 12 |
if ( index_exists( 'items_last_borrower', 'itemnumber' ) ) { |
| 13 |
$dbh->do( |
| 14 |
q{ |
| 15 |
ALTER TABLE items_last_borrower |
| 16 |
DROP FOREIGN KEY items_last_borrower_ibfk_1 |
| 17 |
} |
| 18 |
); |
| 19 |
|
| 20 |
# Drop the unique index |
| 21 |
$dbh->do( |
| 22 |
q{ |
| 23 |
ALTER TABLE items_last_borrower DROP INDEX itemnumber |
| 24 |
} |
| 25 |
); |
| 26 |
|
| 27 |
# Put the FK constraint back, without itemnumber having to be unique |
| 28 |
$dbh->do( |
| 29 |
q{ |
| 30 |
ALTER TABLE items_last_borrower |
| 31 |
ADD CONSTRAINT items_last_borrower_ibfk_1 |
| 32 |
FOREIGN KEY (itemnumber) REFERENCES items (itemnumber) |
| 33 |
ON DELETE CASCADE ON UPDATE CASCADE |
| 34 |
} |
| 35 |
); |
| 36 |
|
| 37 |
say_success( $out, "Adjusted foreign key constraints on items_last_borrower table" ); |
| 38 |
} |
| 39 |
|
| 40 |
# Update system preference from YesNo to Integer |
| 41 |
$dbh->do( |
| 42 |
q{ |
| 43 |
UPDATE systempreferences |
| 44 |
SET type = 'integer', |
| 45 |
explanation = 'Defines the number of borrowers stored per item in the items_last_borrower table' |
| 46 |
WHERE variable = 'StoreLastBorrower' |
| 47 |
} |
| 48 |
); |
| 49 |
|
| 50 |
say_success( $out, "Updated StoreLastBorrower system preference to accept numeric values" ); |
| 51 |
|
| 52 |
}, |
| 53 |
}; |