Skip to content

Commit

Permalink
Merge pull request #2897 from ackwell/patch-1
Browse files Browse the repository at this point in the history
Fix MigrationHelper::dropAllForeignKeysToTable
  • Loading branch information
angrybrad authored May 25, 2018
2 parents 5f038f4 + 036ce4b commit 441993f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/helpers/MigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 441993f

Please sign in to comment.