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();
|
2014-09-18 08:32:21 -07:00
|
|
|
private $keys = array();
|
2014-09-18 08:22:18 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:32:21 -07:00
|
|
|
public function addKey(PhabricatorConfigKeySchema $key) {
|
|
|
|
$name = $key->getName();
|
|
|
|
if (isset($this->keys[$name])) {
|
|
|
|
throw new Exception(
|
|
|
|
pht('Trying to add duplicate key "%s"!', $name));
|
|
|
|
}
|
Fix almost all remaining schemata issues
Summary:
Ref T1191. This fixes nearly every remaining blocker for utf8mb4 -- primarily, overlong keys.
Remaining issue is https://secure.phabricator.com/T1191#77467
Test Plan: I'll annotate inline.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley, hach-que
Maniphest Tasks: T6099, T6129, T6133, T6134, T6150, T6148, T6147, T6146, T6105, T1191
Differential Revision: https://secure.phabricator.com/D10601
2014-10-01 08:18:36 -07:00
|
|
|
$key->setTable($this);
|
2014-09-18 08:32:21 -07:00
|
|
|
$this->keys[$name] = $key;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:18 -07:00
|
|
|
public function getColumns() {
|
|
|
|
return $this->columns;
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:54 -07:00
|
|
|
public function getColumn($key) {
|
|
|
|
return idx($this->getColumns(), $key);
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:32:21 -07:00
|
|
|
public function getKeys() {
|
|
|
|
return $this->keys;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getKey($key) {
|
|
|
|
return idx($this->getKeys(), $key);
|
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:54 -07:00
|
|
|
protected function getSubschemata() {
|
Fix almost all remaining schemata issues
Summary:
Ref T1191. This fixes nearly every remaining blocker for utf8mb4 -- primarily, overlong keys.
Remaining issue is https://secure.phabricator.com/T1191#77467
Test Plan: I'll annotate inline.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley, hach-que
Maniphest Tasks: T6099, T6129, T6133, T6134, T6150, T6148, T6147, T6146, T6105, T1191
Differential Revision: https://secure.phabricator.com/D10601
2014-10-01 08:18:36 -07:00
|
|
|
// NOTE: Keys and columns may have the same name, so make sure we return
|
|
|
|
// everything.
|
|
|
|
|
|
|
|
return array_merge(
|
|
|
|
array_values($this->columns),
|
|
|
|
array_values($this->keys));
|
2014-09-18 08:22:54 -07:00
|
|
|
}
|
|
|
|
|
2014-09-18 08:22:18 -07:00
|
|
|
public function setCollation($collation) {
|
|
|
|
$this->collation = $collation;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCollation() {
|
|
|
|
return $this->collation;
|
|
|
|
}
|
|
|
|
|
2015-01-07 07:33:52 +11:00
|
|
|
protected function compareToSimilarSchema(
|
2014-09-18 08:22:54 -07:00
|
|
|
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();
|
2014-09-18 08:32:21 -07:00
|
|
|
$clone->keys = array();
|
2014-09-18 08:22:54 -07:00
|
|
|
return $clone;
|
2014-09-18 08:22:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|