Commit 52ebcc5e authored by Benjamin Eberlei's avatar Benjamin Eberlei

Prepare Schema SQL collector for Schema support.

parent 7fbeaea1
...@@ -76,7 +76,10 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -76,7 +76,10 @@ class CreateSchemaSqlCollector implements Visitor
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table)
{ {
$this->_createTableQueries = array_merge($this->_createTableQueries, $namespace = $this->getNamespace($table);
$this->_createTableQueries[$namespace] = array_merge(
$this->_createTableQueries[$namespace],
$this->_platform->getCreateTableSQL($table) $this->_platform->getCreateTableSQL($table)
); );
} }
...@@ -92,9 +95,11 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -92,9 +95,11 @@ class CreateSchemaSqlCollector implements Visitor
*/ */
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
{ {
// Append the foreign key constraints SQL $namespace = $this->getNamespace($localTable);
if ($this->_platform->supportsForeignKeyConstraints()) { if ($this->_platform->supportsForeignKeyConstraints()) {
$this->_createFkConstraintQueries = array_merge($this->_createFkConstraintQueries, $this->_createFkConstraintQueries[$namespace] = array_merge(
$this->_createFkConstraintQueries[$namespace],
(array) $this->_platform->getCreateForeignKeySQL( (array) $this->_platform->getCreateForeignKeySQL(
$fkConstraint, $localTable $fkConstraint, $localTable
) )
...@@ -116,11 +121,26 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -116,11 +121,26 @@ class CreateSchemaSqlCollector implements Visitor
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence)
{ {
$this->_createSequenceQueries = array_merge( $namespace = $this->getNamespace($sequence);
$this->_createSequenceQueries, (array)$this->_platform->getCreateSequenceSQL($sequence)
$this->_createSequenceQueries[$namespace] = array_merge(
$this->_createSequenceQueries[$namespace],
(array)$this->_platform->getCreateSequenceSQL($sequence)
); );
} }
private function getNamespace($asset)
{
$namespace = $asset->getNamespaceName() ?: 'default';
if ( !isset($this->_createTableQueries[$namespace])) {
$this->_createTableQueries[$namespace] = array();
$this->_createSequenceQueries[$namespace] = array();
$this->_createFkConstraintQueries[$namespace] = array();
}
return $namespace;
}
/** /**
* @return array * @return array
*/ */
...@@ -138,10 +158,18 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -138,10 +158,18 @@ class CreateSchemaSqlCollector implements Visitor
*/ */
public function getQueries() public function getQueries()
{ {
return array_merge( $sql = array();
$this->_createTableQueries, foreach (array_keys($this->_createTableQueries) as $namespace) {
$this->_createSequenceQueries, if ($this->_platform->supportsSchemas()) {
$this->_createFkConstraintQueries // TODO: Create Schema here
}
$sql = array_merge(
$sql,
$this->_createTableQueries[$namespace],
$this->_createSequenceQueries[$namespace],
$this->_createFkConstraintQueries[$namespace]
); );
} }
return $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