2014-09-18 08:22:18 -07:00
|
|
|
<?php
|
|
|
|
|
2014-09-18 08:22:54 -07:00
|
|
|
final class PhabricatorConfigTableSchema
|
|
|
|
extends PhabricatorConfigStorageSchema {
|
2014-09-18 08:22:18 -07:00
|
|
|
|
|
|
|
private $collation;
|
|
|
|
private $columns = array();
|
|
|
|
|
|
|
|
public function addColumn(PhabricatorConfigColumnSchema $column) {
|
|
|
|
$key = $column->getName();
|
|
|
|
if (isset($this->columns[$key])) {
|
|
|
|
throw new Exception(
|
|
|
|
pht('Trying to add duplicate column "%s"!', $key));
|
|
|
|
}
|
|
|
|
$this->columns[$key] = $column;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColumns() {
|
|
|
|
return $this->columns;
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:54 -07:00
|
|
|
public function getColumn($key) {
|
|
|
|
return idx($this->getColumns(), $key);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getSubschemata() {
|
|
|
|
return $this->getColumns();
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:18 -07:00
|
|
|
public function setCollation($collation) {
|
|
|
|
$this->collation = $collation;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCollation() {
|
|
|
|
return $this->collation;
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:54 -07:00
|
|
|
public function compareToSimilarSchema(
|
|
|
|
PhabricatorConfigStorageSchema $expect) {
|
|
|
|
|
|
|
|
$issues = array();
|
|
|
|
if ($this->getCollation() != $expect->getCollation()) {
|
|
|
|
$issues[] = self::ISSUE_COLLATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $issues;
|
2014-09-18 08:22:18 -07:00
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:54 -07:00
|
|
|
public function newEmptyClone() {
|
|
|
|
$clone = clone $this;
|
|
|
|
$clone->columns = array();
|
|
|
|
return $clone;
|
2014-09-18 08:22:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|