Marcel de Rooy
b1bf07f49c
Old Koha databases probably have it, newer ones might not. See also BZ description. Test plan: [1} Check SHOW CREATE TABLE borrower_attribute_types to see if you have any index and FK constraint on category_code. [2] Run updatedatabase. [3] If you had category_code_fk, it should be replaced. [4] Remove index and constraint again using things like: alter table borrower_attribute_types drop constraint `borrower_attribute_types_ibfk_1`; alter table borrower_attribute_types drop index category_code; [5] Run updatedatabase. [6] You should have KEY category_code and FK borrower_attribute_types_ibfk_1. [7] Run updatedatabase. Idempotent, no changes. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
23 lines
1.1 KiB
Perl
Executable file
23 lines
1.1 KiB
Perl
Executable file
use Modern::Perl;
|
|
|
|
return {
|
|
bug_number => 30449,
|
|
description => "Check borrower_attribute_types FK constraint",
|
|
up => sub {
|
|
my ($args) = @_;
|
|
my ($dbh, $out) = @$args{qw(dbh out)};
|
|
|
|
if( foreign_key_exists('borrower_attribute_types', 'category_code_fk') ) {
|
|
$dbh->do( q|ALTER TABLE borrower_attribute_types DROP CONSTRAINT category_code_fk| );
|
|
if( index_exists('borrower_attribute_types', 'category_code_fk') ) {
|
|
$dbh->do( q|ALTER TABLE borrower_attribute_types DROP INDEX category_code_fk| );
|
|
}
|
|
}
|
|
if( !foreign_key_exists('borrower_attribute_types', 'borrower_attribute_types_ibfk_1') ) {
|
|
if( !index_exists('borrower_attribute_types', 'category_code') ) {
|
|
$dbh->do( q|ALTER TABLE borrower_attribute_types ADD INDEX category_code (category_code)| );
|
|
}
|
|
$dbh->do( q|ALTER TABLE borrower_attribute_types ADD CONSTRAINT borrower_attribute_types_ibfk_1 FOREIGN KEY (`category_code`) REFERENCES `categories` (`categorycode`)| );
|
|
}
|
|
},
|
|
};
|