mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 09:42:41 +01:00
fb8da6f4af
Summary: Ref T1191. The major issue motivation here is that InnoDB keys have a maximum length of 767 bytes. When we move `utf8` colums to `utf8mb4` columns, they'll jump from 3 bytes per character to 4 bytes per character, which may make some indexes too long. Add key schema to help spot this. Also add nullability since it doesn't hurt. Test Plan: See screenshots. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1191 Differential Revision: https://secure.phabricator.com/D10499
77 lines
1.7 KiB
PHP
77 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class PhabricatorConfigTableSchema
|
|
extends PhabricatorConfigStorageSchema {
|
|
|
|
private $collation;
|
|
private $columns = array();
|
|
private $keys = 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 addKey(PhabricatorConfigKeySchema $key) {
|
|
$name = $key->getName();
|
|
if (isset($this->keys[$name])) {
|
|
throw new Exception(
|
|
pht('Trying to add duplicate key "%s"!', $name));
|
|
}
|
|
$this->keys[$name] = $key;
|
|
return $this;
|
|
}
|
|
|
|
public function getColumns() {
|
|
return $this->columns;
|
|
}
|
|
|
|
public function getColumn($key) {
|
|
return idx($this->getColumns(), $key);
|
|
}
|
|
|
|
public function getKeys() {
|
|
return $this->keys;
|
|
}
|
|
|
|
public function getKey($key) {
|
|
return idx($this->getKeys(), $key);
|
|
}
|
|
|
|
protected function getSubschemata() {
|
|
return array_merge($this->getColumns(), $this->getKeys());
|
|
}
|
|
|
|
public function setCollation($collation) {
|
|
$this->collation = $collation;
|
|
return $this;
|
|
}
|
|
|
|
public function getCollation() {
|
|
return $this->collation;
|
|
}
|
|
|
|
public function compareToSimilarSchema(
|
|
PhabricatorConfigStorageSchema $expect) {
|
|
|
|
$issues = array();
|
|
if ($this->getCollation() != $expect->getCollation()) {
|
|
$issues[] = self::ISSUE_COLLATION;
|
|
}
|
|
|
|
return $issues;
|
|
}
|
|
|
|
public function newEmptyClone() {
|
|
$clone = clone $this;
|
|
$clone->columns = array();
|
|
$clone->keys = array();
|
|
return $clone;
|
|
}
|
|
|
|
}
|