Commit 2ae916ad authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge branch 'DBAL-591' into 2.4

parents 4e024dcb e1cd82a5
...@@ -484,7 +484,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -484,7 +484,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql[] = 'ALTER TABLE ' . $diff->name . ' RENAME TO ' . $diff->newName; $sql[] = 'ALTER TABLE ' . $diff->name . ' RENAME TO ' . $diff->newName;
} }
$sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff), $commentsSQL); $sql = array_merge($this->getPreAlterTableIndexForeignKeySQL($diff), $sql, $this->getPostAlterTableIndexForeignKeySQL($diff), $commentsSQL);
} }
return array_merge($sql, $tableSql, $columnSql); return array_merge($sql, $tableSql, $columnSql);
......
...@@ -363,5 +363,32 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase ...@@ -363,5 +363,32 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$this->assertEquals($expectedSql, $sql); $this->assertEquals($expectedSql, $sql);
} }
/**
* @group DBAL-365
*/
public function testDroppingConstraintsBeforeColumns()
{
$newTable = new Table('mytable');
$newTable->addColumn('id', 'integer');
$newTable->setPrimaryKey(array('id'));
$oldTable = clone $newTable;
$oldTable->addColumn('parent_id', 'integer');
$oldTable->addUnnamedForeignKeyConstraint('mytable', array('parent_id'), array('id'));
$comparator = new \Doctrine\DBAL\Schema\Comparator();
$tableDiff = $comparator->diffTable($oldTable, $newTable);
$sql = $this->_platform->getAlterTableSQL($tableDiff);
$expectedSql = array(
'ALTER TABLE mytable DROP CONSTRAINT FK_6B2BD609727ACA70',
'DROP INDEX IDX_6B2BD609727ACA70',
'ALTER TABLE mytable DROP parent_id',
);
$this->assertEquals($expectedSql, $sql);
}
} }
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