Added test and fix for DBAL-392 Moving entity relationship doesn't move foreign key in mysql table

parent c125e229
......@@ -317,6 +317,10 @@ class Comparator
return true;
}
if (strtolower($key1->getForeignTableName()) != strtolower($key2->getForeignTableName())) {
return true;
}
if ($key1->onUpdate() != $key2->onUpdate()) {
return true;
}
......
......@@ -486,6 +486,29 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(1, count($tableDiff->changedForeignKeys));
}
public function testMovedForeignKeyForeignTable()
{
$tableForeign = new Table("bar");
$tableForeign->addColumn('id', 'integer');
$tableForeign2 = new Table("bar2");
$tableForeign2->addColumn('id', 'integer');
$table1 = new Table("foo");
$table1->addColumn('fk', 'integer');
$table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
$table2 = new Table("foo");
$table2->addColumn('fk', 'integer');
$table2->addForeignKeyConstraint($tableForeign2, array('fk'), array('id'));
$c = new Comparator();
$tableDiff = $c->diffTable($table1, $table2);
$this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
$this->assertEquals(1, count($tableDiff->changedForeignKeys));
}
public function testTablesCaseInsensitive()
{
$schemaA = new Schema();
......
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