diff --git a/src/helpers/MigrationHelper.php b/src/helpers/MigrationHelper.php index b2695e03140..70925e5647a 100644 --- a/src/helpers/MigrationHelper.php +++ b/src/helpers/MigrationHelper.php @@ -545,21 +545,15 @@ public static function dropAllForeignKeysToTable(string $tableName, Migration $m $schema = $db->getSchema(); $rawTableName = $schema->getRawTableName($tableName); $table = $db->getTableSchema($rawTableName); - $otherColumns = []; foreach ($table->getColumnNames() as $columnName) { $fks = static::findForeignKeysTo($rawTableName, $columnName); foreach ($fks as $otherTable => $row) { - foreach ($row as $columnInfo) { - foreach ($columnInfo as $count => $value) { - if ($count !== 0) { - $otherColumns[] = $count; - } - } + foreach ($row as $fk) { + $otherColumns = static::_getColumnsForFK($fk, true); + static::dropForeignKeyIfExists($otherTable, $otherColumns, $migration); } - - static::dropForeignKeyIfExists($otherTable, $otherColumns, $migration); } } }