diff --git a/installer/data/mysql/db_revs/220600020.pl b/installer/data/mysql/db_revs/220600020.pl index ccd6a0a518..b023204410 100755 --- a/installer/data/mysql/db_revs/220600020.pl +++ b/installer/data/mysql/db_revs/220600020.pl @@ -31,11 +31,19 @@ return { UPDATE reserves SET branchcode = ( SELECT branchcode FROM branches LIMIT 1) WHERE branchcode IS NULL; }); + # Remove FOREIGN KEY CONSTRAINT + $dbh->do(q{ + ALTER TABLE reserves DROP FOREIGN KEY reserves_ibfk_4; + }); # Set the NOT NULL configuration $dbh->do(q{ ALTER TABLE reserves MODIFY COLUMN `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at' }); + # Replace the constraint + $dbh->do(q{ + ALTER TABLE reserves ADD CONSTRAINT reserves_ibfk_4 FOREIGN KEY (branchcode) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE; + }); # Print useful stuff here say $out "Removed NULL option from branchcode for reserves";