Bug 39107: (QA follow-up) Use existing foreign_key_exists function

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4a57c1f779)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Emily Lamancusa 2026-04-24 11:25:22 -04:00 committed by Jacob O'Mara
parent 205a9c27d5
commit 76345c7eba
No known key found for this signature in database
1 changed files with 1 additions and 13 deletions

View File

@ -8,19 +8,7 @@ return {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
# Check if the foreign key exists before trying to drop it
my $fk_exists = $dbh->selectrow_array(
q{
SELECT COUNT(*)
FROM information_schema.TABLE_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = DATABASE()
AND TABLE_NAME = 'illrequests'
AND CONSTRAINT_NAME = 'illrequests_safk'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
}
);
if ($fk_exists) {
if ( foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) {
$dbh->do(q{ ALTER TABLE illrequests DROP FOREIGN KEY illrequests_safk });
say_success( $out, "Removed illrequests_safk FK constraint on illrequests.status_alias" );
} else {