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>
This commit is contained in:
Emily Lamancusa 2026-04-24 11:25:22 -04:00 committed by Lucas Gass
parent fe24b5030e
commit 4a57c1f779
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
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 {