Lines 8-21
return {
Link Here
|
8 |
my ($args) = @_; |
8 |
my ($args) = @_; |
9 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
9 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
10 |
|
10 |
|
11 |
# Drop the foreign key constraint temporarily |
|
|
12 |
if ( index_exists( 'items_last_borrower', 'itemnumber' ) ) { |
11 |
if ( index_exists( 'items_last_borrower', 'itemnumber' ) ) { |
13 |
$dbh->do( |
12 |
$dbh->do('SET FOREIGN_KEY_CHECKS=0'); |
14 |
q{ |
|
|
15 |
ALTER TABLE items_last_borrower |
16 |
DROP FOREIGN KEY items_last_borrower_ibfk_1 |
17 |
} |
18 |
); |
19 |
|
13 |
|
20 |
# Drop the unique index |
14 |
# Drop the unique index |
21 |
$dbh->do( |
15 |
$dbh->do( |
Lines 23-38
return {
Link Here
|
23 |
ALTER TABLE items_last_borrower DROP INDEX itemnumber |
17 |
ALTER TABLE items_last_borrower DROP INDEX itemnumber |
24 |
} |
18 |
} |
25 |
); |
19 |
); |
26 |
|
20 |
$dbh->do('SET FOREIGN_KEY_CHECKS=1'); |
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 |
|
21 |
|
37 |
say_success( $out, "Adjusted foreign key constraints on items_last_borrower table" ); |
22 |
say_success( $out, "Adjusted foreign key constraints on items_last_borrower table" ); |
38 |
} |
23 |
} |
39 |
- |
|
|