Fixed SchemaTool which was failing to dropSchema due to foreignKeyContraint checks. Fixes DDC-1126
This commit is contained in:
parent
26bd3e3811
commit
fe66d8bc04
@ -598,7 +598,11 @@ class SchemaTool
|
|||||||
*/
|
*/
|
||||||
public function getDropSchemaSQL(array $classes)
|
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();
|
$sql = array();
|
||||||
$orderedTables = array();
|
$orderedTables = array();
|
||||||
@ -633,13 +637,18 @@ class SchemaTool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$supportsForeignKeyConstraints = $conn->getDatabasePlatform()->supportsForeignKeyConstraints();
|
||||||
$dropTablesSql = array();
|
$dropTablesSql = array();
|
||||||
|
|
||||||
foreach ($orderedTables AS $tableName) {
|
foreach ($orderedTables AS $tableName) {
|
||||||
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
|
if ($supportsForeignKeyConstraints) {
|
||||||
$foreignKeys = $sm->listTableForeignKeys($tableName);
|
$foreignKeys = $sm->listTableForeignKeys($tableName);
|
||||||
|
|
||||||
foreach ($foreignKeys AS $foreignKey) {
|
foreach ($foreignKeys AS $foreignKey) {
|
||||||
$sql[] = $this->_platform->getDropForeignKeySQL($foreignKey, $tableName);
|
$sql[] = $this->_platform->getDropForeignKeySQL($foreignKey, $tableName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$dropTablesSql[] = $this->_platform->getDropTableSQL($tableName);
|
$dropTablesSql[] = $this->_platform->getDropTableSQL($tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user