Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigDatabaseSchema.php
<?php | <?php | ||||
final class PhabricatorConfigDatabaseSchema extends Phobject { | final class PhabricatorConfigDatabaseSchema | ||||
extends PhabricatorConfigStorageSchema { | |||||
private $name; | |||||
private $characterSet; | private $characterSet; | ||||
private $collation; | private $collation; | ||||
private $tables = array(); | private $tables = array(); | ||||
public function addTable(PhabricatorConfigTableSchema $table) { | public function addTable(PhabricatorConfigTableSchema $table) { | ||||
$key = $table->getName(); | $key = $table->getName(); | ||||
if (isset($this->tables[$key])) { | if (isset($this->tables[$key])) { | ||||
throw new Exception( | throw new Exception( | ||||
pht('Trying to add duplicate table "%s"!', $key)); | pht('Trying to add duplicate table "%s"!', $key)); | ||||
} | } | ||||
$this->tables[$key] = $table; | $this->tables[$key] = $table; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getTables() { | public function getTables() { | ||||
return $this->tables; | return $this->tables; | ||||
} | } | ||||
public function getTable($key) { | public function getTable($key) { | ||||
return idx($this->tables, $key); | return idx($this->tables, $key); | ||||
} | } | ||||
public function isSameSchema(PhabricatorConfigDatabaseSchema $expect) { | protected function getSubschemata() { | ||||
return ($this->toDictionary() === $expect->toDictionary()); | return $this->getTables(); | ||||
} | } | ||||
public function toDictionary() { | public function compareToSimilarSchema( | ||||
return array( | PhabricatorConfigStorageSchema $expect) { | ||||
'name' => $this->getName(), | |||||
'characterSet' => $this->getCharacterSet(), | $issues = array(); | ||||
'collation' => $this->getCollation(), | if ($this->getCharacterSet() != $expect->getCharacterSet()) { | ||||
); | $issues[] = self::ISSUE_CHARSET; | ||||
} | |||||
if ($this->getCollation() != $expect->getCollation()) { | |||||
$issues[] = self::ISSUE_COLLATION; | |||||
} | |||||
return $issues; | |||||
} | |||||
public function newEmptyClone() { | |||||
$clone = clone $this; | |||||
$clone->tables = array(); | |||||
return $clone; | |||||
} | } | ||||
public function setCollation($collation) { | public function setCollation($collation) { | ||||
$this->collation = $collation; | $this->collation = $collation; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCollation() { | public function getCollation() { | ||||
return $this->collation; | return $this->collation; | ||||
} | } | ||||
public function setCharacterSet($character_set) { | public function setCharacterSet($character_set) { | ||||
$this->characterSet = $character_set; | $this->characterSet = $character_set; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCharacterSet() { | public function getCharacterSet() { | ||||
return $this->characterSet; | return $this->characterSet; | ||||
} | } | ||||
public function setName($name) { | |||||
$this->name = $name; | |||||
return $this; | |||||
} | |||||
public function getName() { | |||||
return $this->name; | |||||
} | |||||
} | } |