2014-09-18 17:22:18 +02:00
|
|
|
<?php
|
|
|
|
|
2014-09-18 17:22:54 +02:00
|
|
|
final class PhabricatorConfigDatabaseSchema
|
|
|
|
extends PhabricatorConfigStorageSchema {
|
2014-09-18 17:22:18 +02:00
|
|
|
|
|
|
|
private $characterSet;
|
|
|
|
private $collation;
|
|
|
|
private $tables = array();
|
2016-01-21 21:59:19 +01:00
|
|
|
private $accessDenied;
|
2014-09-18 17:22:18 +02:00
|
|
|
|
|
|
|
public function addTable(PhabricatorConfigTableSchema $table) {
|
|
|
|
$key = $table->getName();
|
|
|
|
if (isset($this->tables[$key])) {
|
2017-04-20 00:49:19 +02:00
|
|
|
|
|
|
|
if ($key == 'application_application') {
|
|
|
|
// NOTE: This is a terrible hack to allow Application subclasses to
|
|
|
|
// extend LiskDAO so we can apply transactions to them.
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-09-18 17:22:18 +02:00
|
|
|
throw new Exception(
|
|
|
|
pht('Trying to add duplicate table "%s"!', $key));
|
|
|
|
}
|
|
|
|
$this->tables[$key] = $table;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTables() {
|
|
|
|
return $this->tables;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTable($key) {
|
|
|
|
return idx($this->tables, $key);
|
|
|
|
}
|
|
|
|
|
2014-09-18 17:22:54 +02:00
|
|
|
protected function getSubschemata() {
|
|
|
|
return $this->getTables();
|
2014-09-18 17:22:18 +02:00
|
|
|
}
|
|
|
|
|
2015-01-06 21:33:52 +01:00
|
|
|
protected function compareToSimilarSchema(
|
2014-09-18 17:22:54 +02:00
|
|
|
PhabricatorConfigStorageSchema $expect) {
|
|
|
|
|
|
|
|
$issues = array();
|
2016-01-21 21:59:19 +01:00
|
|
|
if ($this->getAccessDenied()) {
|
|
|
|
$issues[] = self::ISSUE_ACCESSDENIED;
|
|
|
|
} else {
|
|
|
|
if ($this->getCharacterSet() != $expect->getCharacterSet()) {
|
|
|
|
$issues[] = self::ISSUE_CHARSET;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getCollation() != $expect->getCollation()) {
|
|
|
|
$issues[] = self::ISSUE_COLLATION;
|
|
|
|
}
|
2014-09-18 17:22:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $issues;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function newEmptyClone() {
|
|
|
|
$clone = clone $this;
|
|
|
|
$clone->tables = array();
|
|
|
|
return $clone;
|
2014-09-18 17:22:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setCollation($collation) {
|
|
|
|
$this->collation = $collation;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCollation() {
|
|
|
|
return $this->collation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCharacterSet($character_set) {
|
|
|
|
$this->characterSet = $character_set;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCharacterSet() {
|
|
|
|
return $this->characterSet;
|
|
|
|
}
|
|
|
|
|
2016-01-21 21:59:19 +01:00
|
|
|
public function setAccessDenied($access_denied) {
|
|
|
|
$this->accessDenied = $access_denied;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAccessDenied() {
|
|
|
|
return $this->accessDenied;
|
|
|
|
}
|
|
|
|
|
2014-09-18 17:22:18 +02:00
|
|
|
}
|