Commit 9a018f44 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge branch 'DDC-1266' into 2.1.x

parents cc09204a 71778daa
...@@ -42,32 +42,35 @@ use Doctrine\DBAL\Platforms\AbstractPlatform, ...@@ -42,32 +42,35 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
class DropSchemaSqlCollector implements Visitor class DropSchemaSqlCollector implements Visitor
{ {
/** /**
* @var array * @var \SplObjectStorage
*/ */
private $_constraints = array(); private $constraints;
/** /**
* @var array * @var \SplObjectStorage
*/ */
private $_sequences = array(); private $sequences;
/** /**
* @var array * @var \SplObjectStorage
*/ */
private $_tables = array(); private $tables;
/** /**
* *
* @var \Doctrine\DBAL\Platforms\AbstractPlatform * @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/ */
private $_platform = null; private $platform;
/** /**
* @param AbstractPlatform $platform * @param AbstractPlatform $platform
*/ */
public function __construct(AbstractPlatform $platform) public function __construct(AbstractPlatform $platform)
{ {
$this->_platform = $platform; $this->platform = $platform;
$this->constraints = new \SplObjectStorage();
$this->sequences = new \SplObjectStorage();
$this->tables = new \SplObjectStorage();
} }
/** /**
...@@ -75,7 +78,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -75,7 +78,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema)
{ {
} }
/** /**
...@@ -83,7 +86,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -83,7 +86,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table)
{ {
$this->_tables[] = $this->_platform->getDropTableSQL($table->getQuotedName($this->_platform)); $this->tables->attach($table);
} }
/** /**
...@@ -91,7 +94,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -91,7 +94,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptColumn(Table $table, Column $column) public function acceptColumn(Table $table, Column $column)
{ {
} }
/** /**
...@@ -104,7 +107,8 @@ class DropSchemaSqlCollector implements Visitor ...@@ -104,7 +107,8 @@ class DropSchemaSqlCollector implements Visitor
throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint); throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint);
} }
$this->_constraints[] = $this->_platform->getDropForeignKeySQL($fkConstraint->getQuotedName($this->_platform), $localTable->getQuotedName($this->_platform)); $this->constraints->attach($fkConstraint);
$this->constraints[$fkConstraint] = $localTable;
} }
/** /**
...@@ -113,7 +117,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -113,7 +117,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptIndex(Table $table, Index $index) public function acceptIndex(Table $table, Index $index)
{ {
} }
/** /**
...@@ -121,7 +125,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -121,7 +125,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence)
{ {
$this->_sequences[] = $this->_platform->getDropSequenceSQL($sequence->getQuotedName($this->_platform)); $this->sequences->attach($sequence);
} }
/** /**
...@@ -129,7 +133,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -129,7 +133,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function clearQueries() public function clearQueries()
{ {
$this->_constraints = $this->_sequences = $this->_tables = array(); $this->constraints = $this->sequences = $this->tables = array();
} }
/** /**
...@@ -137,6 +141,20 @@ class DropSchemaSqlCollector implements Visitor ...@@ -137,6 +141,20 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function getQueries() public function getQueries()
{ {
return array_merge($this->_constraints, $this->_sequences, $this->_tables); $sql = array();
foreach ($this->constraints AS $fkConstraint) {
$localTable = $this->constraints[$fkConstraint];
$sql[] = $this->platform->getDropForeignKeySQL($fkConstraint->getQuotedName($this->platform), $localTable->getQuotedName($this->platform));
}
foreach ($this->sequences AS $sequence) {
$sql[] = $this->platform->getDropSequenceSQL($sequence->getQuotedName($this->platform));
}
foreach ($this->tables AS $table) {
$sql[] = $this->platform->getDropTableSQL($table->getQuotedName($this->platform));
}
return $sql;
} }
} }
Subproject commit b385ca770888248241bd3086a40d5b3bd082a706 Subproject commit 40f1bf16e84ddc5291a6a63aa00b9879c40e3500
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