refactor plan created

This commit is contained in:
Kalana B. Thilakarathna
2026-09-18 12:18:00 +05:30
parent 03d01d4c4e
commit c8c04c357d
2 changed files with 17 additions and 18 deletions
@@ -898,23 +898,7 @@ namespace Distribution.Migrations
private static void DropForeignKeyIfExists(MigrationBuilder migrationBuilder, string tableName, string constraintName)
{
migrationBuilder.Sql($"""
SET @sql = IF(
EXISTS(
SELECT 1
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = DATABASE()
AND TABLE_NAME = '{tableName}'
AND CONSTRAINT_NAME = '{constraintName}'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
),
'ALTER TABLE `{tableName}` DROP FOREIGN KEY `{constraintName}`',
'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
""");
migrationBuilder.Sql($"ALTER TABLE `{tableName}` DROP FOREIGN KEY IF EXISTS `{constraintName}`;");
}
private static void DropIndexIfExists(MigrationBuilder migrationBuilder, string tableName, string indexName)