|
Line 0
Link Here
|
| 0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
use Koha::Installer::Output qw(say_warning say_failure say_success say_info); |
| 3 |
|
| 4 |
return { |
| 5 |
bug_number => "37346", |
| 6 |
description => "The VirtualShelf object should have an 'owner' accessor to return the related owner Koha::Patron", |
| 7 |
up => sub { |
| 8 |
my ($args) = @_; |
| 9 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
| 10 |
|
| 11 |
if ( !column_exists( 'virtualshelves', 'owner_id' ) ) { |
| 12 |
$dbh->do( |
| 13 |
q{ |
| 14 |
ALTER TABLE virtualshelves |
| 15 |
RENAME COLUMN owner TO owner_id |
| 16 |
} |
| 17 |
); |
| 18 |
|
| 19 |
say_success $out, 'Renamed owner column to owner_id in virtualshelves table'; |
| 20 |
} |
| 21 |
|
| 22 |
if ( foreign_key_exists( 'virtualshelves', 'virtualshelves_ibfk_1' ) ) { |
| 23 |
$dbh->do( |
| 24 |
q{ |
| 25 |
ALTER TABLE virtualshelves |
| 26 |
DROP FOREIGN KEY virtualshelves_ibfk_1 |
| 27 |
} |
| 28 |
); |
| 29 |
$dbh->do( |
| 30 |
q{ |
| 31 |
ALTER TABLE virtualshelves |
| 32 |
ADD CONSTRAINT virtualshelves_ibfk_1 |
| 33 |
FOREIGN KEY (`owner_id`) |
| 34 |
REFERENCES `borrowers` (`borrowernumber`) |
| 35 |
ON DELETE SET NULL |
| 36 |
ON UPDATE SET NULL |
| 37 |
} |
| 38 |
); |
| 39 |
|
| 40 |
say_success $out, 'Dropped and recreated owner_id foreign key in virtualshelves'; |
| 41 |
} |
| 42 |
}, |
| 43 |
}; |