Skip to content

Commit

Permalink
Fix MigrationHelper::dropAllForeignKeysToTable
Browse files Browse the repository at this point in the history
  • Loading branch information
Saxon Landers authored May 17, 2018
1 parent d8019db commit 036ce4b
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 036ce4b

Please sign in to comment.