Check for foreign table name on removed tables foreign key

According to the comment

// deleting duplicated foreign keys present on both on the orphanedForeignKey
// and the removedForeignKeys from changedTables

A check must be had on the $removedForeignKey so it does point on the removed table. Currently it does unset all keys removal even the one pointing on other table.
parent 9e795469
......@@ -116,6 +116,10 @@ class Comparator
$localTableName = strtolower($foreignKey->getLocalTableName());
if (isset($diff->changedTables[$localTableName])) {
foreach ($diff->changedTables[$localTableName]->removedForeignKeys as $key => $removedForeignKey) {
//We check if the key is from the removed table if not we skip
if($tableName !== strtolower($removedForeignKey->getForeignTableName())) {
continue;
}
unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment