1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Fixed SchemaTool which was failing to dropSchema due to foreignKeyContraint checks. Fixes DDC-1126

This commit is contained in:
Guilherme Blanco 2011-04-26 12:32:04 -03:00
parent 26bd3e3811
commit fe66d8bc04

View File

@ -598,7 +598,11 @@ class SchemaTool
*/
public function getDropSchemaSQL(array $classes)
{
$sm = $this->_em->getConnection()->getSchemaManager();
/* @var $conn \Doctrine\DBAL\Connection */
$conn = $this->_em->getConnection();
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
$sm = $conn->getSchemaManager();
$sql = array();
$orderedTables = array();
@ -633,13 +637,18 @@ class SchemaTool
}
}
$supportsForeignKeyConstraints = $conn->getDatabasePlatform()->supportsForeignKeyConstraints();
$dropTablesSql = array();
foreach ($orderedTables AS $tableName) {
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
$foreignKeys = $sm->listTableForeignKeys($tableName);
foreach ($foreignKeys AS $foreignKey) {
$sql[] = $this->_platform->getDropForeignKeySQL($foreignKey, $tableName);
if ($supportsForeignKeyConstraints) {
$foreignKeys = $sm->listTableForeignKeys($tableName);
foreach ($foreignKeys AS $foreignKey) {
$sql[] = $this->_platform->getDropForeignKeySQL($foreignKey, $tableName);
}
}
$dropTablesSql[] = $this->_platform->getDropTableSQL($tableName);
}