refactor plan created
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user