mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 10:22:42 +01:00
b24e36706d
Summary: Ref T1191. This builds on the "view of the database as it exists" by building a view of the database as it is expected to exist (this is mostly empty for now) and comparing the two. We now render a view of the "comparison schema", which is the actual schema merged with the expected schema and annotated with the differences. (I'm merging them like this because it makes it easier to handle both "missing" and "surpulus" warnings in a consistent way. If we tried to annotate just the actual or expected schema, the absence of components which are expected to exist is messy to handle.) Test Plan: See screenshots. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1191 Differential Revision: https://secure.phabricator.com/D10496
71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorConfigDatabaseSchema
|
|
extends PhabricatorConfigStorageSchema {
|
|
|
|
private $characterSet;
|
|
private $collation;
|
|
private $tables = array();
|
|
|
|
public function addTable(PhabricatorConfigTableSchema $table) {
|
|
$key = $table->getName();
|
|
if (isset($this->tables[$key])) {
|
|
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);
|
|
}
|
|
|
|
protected function getSubschemata() {
|
|
return $this->getTables();
|
|
}
|
|
|
|
public function compareToSimilarSchema(
|
|
PhabricatorConfigStorageSchema $expect) {
|
|
|
|
$issues = array();
|
|
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) {
|
|
$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;
|
|
}
|
|
|
|
}
|