Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15389375
D10526.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Referenced Files
None
Subscribers
None
D10526.id.diff
View Options
diff --git a/resources/sql/autopatches/20140919.schema.03.dropaux.sql b/resources/sql/autopatches/20140919.schema.03.dropaux.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140919.schema.03.dropaux.sql
@@ -0,0 +1 @@
+DROP TABLE {$NAMESPACE}_maniphest.maniphest_taskauxiliarystorage;
diff --git a/resources/sql/autopatches/20140919.schema.04.droptaskproj.sql b/resources/sql/autopatches/20140919.schema.04.droptaskproj.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140919.schema.04.droptaskproj.sql
@@ -0,0 +1 @@
+DROP TABLE {$NAMESPACE}_maniphest.maniphest_taskproject;
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -918,6 +918,7 @@
'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php',
'ManiphestReplyHandler' => 'applications/maniphest/mail/ManiphestReplyHandler.php',
'ManiphestReportController' => 'applications/maniphest/controller/ManiphestReportController.php',
+ 'ManiphestSchemaSpec' => 'applications/maniphest/storage/ManiphestSchemaSpec.php',
'ManiphestSearchIndexer' => 'applications/maniphest/search/ManiphestSearchIndexer.php',
'ManiphestStatusConfigOptionType' => 'applications/maniphest/config/ManiphestStatusConfigOptionType.php',
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
@@ -3800,6 +3801,7 @@
'ManiphestRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler',
'ManiphestReportController' => 'ManiphestController',
+ 'ManiphestSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'ManiphestStatusConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'ManiphestSubpriorityController' => 'ManiphestController',
diff --git a/src/applications/config/controller/PhabricatorConfigDatabaseStatusController.php b/src/applications/config/controller/PhabricatorConfigDatabaseStatusController.php
--- a/src/applications/config/controller/PhabricatorConfigDatabaseStatusController.php
+++ b/src/applications/config/controller/PhabricatorConfigDatabaseStatusController.php
@@ -280,6 +280,7 @@
$collation_issue = PhabricatorConfigStorageSchema::ISSUE_COLLATION;
$nullable_issue = PhabricatorConfigStorageSchema::ISSUE_NULLABLE;
$unique_issue = PhabricatorConfigStorageSchema::ISSUE_UNIQUE;
+ $columns_issue = PhabricatorConfigStorageSchema::ISSUE_KEYCOLUMNS;
$database = $comp->getDatabase($database_name);
if (!$database) {
@@ -377,13 +378,14 @@
$status = $key->getStatus();
$size = 0;
- foreach ($key->getColumnNames() as $column_name) {
+ foreach ($key->getColumnNames() as $column_spec) {
+ list($column_name, $prefix) = $key->getKeyColumnAndPrefix($column_spec);
$column = $table->getColumn($column_name);
if (!$column) {
$size = 0;
break;
}
- $size += $column->getKeyByteLength();
+ $size += $column->getKeyByteLength($prefix);
}
$size_formatted = null;
@@ -406,7 +408,9 @@
$key_name.'/'),
),
$key_name),
- implode(', ', $key->getColumnNames()),
+ $this->renderAttr(
+ implode(', ', $key->getColumnNames()),
+ $key->hasIssue($columns_issue)),
$this->renderAttr(
$this->renderBoolean($key->getUnique()),
$key->hasIssue($unique_issue)),
diff --git a/src/applications/config/schema/PhabricatorConfigColumnSchema.php b/src/applications/config/schema/PhabricatorConfigColumnSchema.php
--- a/src/applications/config/schema/PhabricatorConfigColumnSchema.php
+++ b/src/applications/config/schema/PhabricatorConfigColumnSchema.php
@@ -58,20 +58,47 @@
return $this->characterSet;
}
- public function getKeyByteLength() {
+ public function getKeyByteLength($prefix = null) {
$type = $this->getColumnType();
$matches = null;
if (preg_match('/^varchar\((\d+)\)$/', $type, $matches)) {
// For utf8mb4, each character requires 4 bytes.
- return ((int)$matches[1]) * 4;
+ $size = (int)$matches[1];
+ if ($prefix && $prefix < $size) {
+ $size = $prefix;
+ }
+ return $size * 4;
}
$matches = null;
if (preg_match('/^char\((\d+)\)$/', $type, $matches)) {
// We use char() only for fixed-length binary data, so its size
// is always the column size.
- return ((int)$matches[1]);
+ $size = (int)$matches[1];
+ if ($prefix && $prefix < $size) {
+ $size = $prefix;
+ }
+ return $size;
+ }
+
+ // The "long..." types are arbitrarily long, so just use a big number to
+ // get the point across. In practice, these should always index only a
+ // prefix.
+ if ($type == 'longtext') {
+ $size = (1 << 16);
+ if ($prefix && $prefix < $size) {
+ $size = $prefix;
+ }
+ return $size * 4;
+ }
+
+ if ($type == 'longblob') {
+ $size = (1 << 16);
+ if ($prefix && $prefix < $size) {
+ $size = $prefix;
+ }
+ return $size * 1;
}
switch ($type) {
diff --git a/src/applications/config/schema/PhabricatorConfigKeySchema.php b/src/applications/config/schema/PhabricatorConfigKeySchema.php
--- a/src/applications/config/schema/PhabricatorConfigKeySchema.php
+++ b/src/applications/config/schema/PhabricatorConfigKeySchema.php
@@ -28,6 +28,15 @@
return array();
}
+ public function getKeyColumnAndPrefix($column_name) {
+ $matches = null;
+ if (preg_match('/^(.*)\((\d+)\)\z/', $column_name, $matches)) {
+ return array($matches[1], (int)$matches[2]);
+ } else {
+ return array($column_name, null);
+ }
+ }
+
public function compareToSimilarSchema(
PhabricatorConfigStorageSchema $expect) {
diff --git a/src/applications/config/schema/PhabricatorConfigSchemaQuery.php b/src/applications/config/schema/PhabricatorConfigSchemaQuery.php
--- a/src/applications/config/schema/PhabricatorConfigSchemaQuery.php
+++ b/src/applications/config/schema/PhabricatorConfigSchemaQuery.php
@@ -115,9 +115,20 @@
foreach ($keys as $key_name => $key_pieces) {
$key_pieces = isort($key_pieces, 'Seq_in_index');
$head = head($key_pieces);
+
+ // This handles string indexes which index only a prefix of a field.
+ $column_names = array();
+ foreach ($key_pieces as $piece) {
+ $name = $piece['Column_name'];
+ if ($piece['Sub_part']) {
+ $name = $name.'('.$piece['Sub_part'].')';
+ }
+ $column_names[] = $name;
+ }
+
$key_schema = id(new PhabricatorConfigKeySchema())
->setName($key_name)
- ->setColumnNames(ipull($key_pieces, 'Column_name'))
+ ->setColumnNames($column_names)
->setUnique(!$head['Non_unique']);
$table_schema->addKey($key_schema);
diff --git a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php
--- a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php
+++ b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php
@@ -56,6 +56,16 @@
}
}
+ protected function buildCustomFieldSchemata(
+ PhabricatorLiskDAO $storage,
+ array $indexes) {
+
+ $this->buildLiskObjectSchema($storage);
+ foreach ($indexes as $index) {
+ $this->buildLiskObjectSchema($index);
+ }
+ }
+
private function buildLiskObjectSchema(PhabricatorLiskDAO $object) {
$this->buildRawSchema(
$object->getApplicationName(),
@@ -123,6 +133,10 @@
array(
'PRIMARY' => array(
'columns' => array('src', 'type', 'dst'),
+ 'unique' => true,
+ ),
+ 'src' => array(
+ 'columns' => array('src', 'type', 'dateCreated', 'seq'),
),
));
@@ -136,6 +150,7 @@
array(
'PRIMARY' => array(
'columns' => array('id'),
+ 'unique' => true,
),
));
}
@@ -217,6 +232,9 @@
case 'uint64':
$column_type = 'bigint(20) unsigned';
break;
+ case 'sint64':
+ $column_type = 'bigint(20)';
+ break;
case 'phid':
case 'policy';
$column_type = 'varchar(64)';
diff --git a/src/applications/maniphest/storage/ManiphestNameIndex.php b/src/applications/maniphest/storage/ManiphestNameIndex.php
--- a/src/applications/maniphest/storage/ManiphestNameIndex.php
+++ b/src/applications/maniphest/storage/ManiphestNameIndex.php
@@ -12,6 +12,18 @@
public function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
+ self::CONFIG_COLUMN_SCHEMA => array(
+ 'indexedObjectName' => 'text128',
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_phid' => array(
+ 'columns' => array('indexedObjectPHID'),
+ 'unique' => true,
+ ),
+ 'key_name' => array(
+ 'columns' => array('indexedObjectName'),
+ ),
+ ),
) + parent::getConfiguration();
}
diff --git a/src/applications/maniphest/storage/ManiphestSchemaSpec.php b/src/applications/maniphest/storage/ManiphestSchemaSpec.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/storage/ManiphestSchemaSpec.php
@@ -0,0 +1,22 @@
+<?php
+
+final class ManiphestSchemaSpec
+ extends PhabricatorConfigSchemaSpec {
+
+ public function buildSchemata() {
+ $this->buildLiskSchemata('ManiphestDAO');
+
+ $this->buildEdgeSchemata(new ManiphestTask());
+ $this->buildTransactionSchema(
+ new ManiphestTransaction(),
+ new ManiphestTransactionComment());
+
+ $this->buildCustomFieldSchemata(
+ new ManiphestCustomFieldStorage(),
+ array(
+ new ManiphestCustomFieldNumericIndex(),
+ new ManiphestCustomFieldStringIndex(),
+ ));
+ }
+
+}
diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php
--- a/src/applications/maniphest/storage/ManiphestTask.php
+++ b/src/applications/maniphest/storage/ManiphestTask.php
@@ -67,6 +67,49 @@
'attached' => self::SERIALIZATION_JSON,
'projectPHIDs' => self::SERIALIZATION_JSON,
),
+ self::CONFIG_COLUMN_SCHEMA => array(
+ 'ownerPHID' => 'phid?',
+ 'status' => 'text12',
+ 'priority' => 'uint32',
+ 'title' => 'text',
+ 'originalTitle' => 'text',
+ 'description' => 'text',
+ 'mailKey' => 'bytes20',
+ 'ownerOrdering' => 'text64?',
+ 'originalEmailSource' => 'text255?',
+ 'subpriority' => 'double',
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_phid' => null,
+ 'phid' => array(
+ 'columns' => array('phid'),
+ 'unique' => true,
+ ),
+ 'priority' => array(
+ 'columns' => array('priority', 'status'),
+ ),
+ 'status' => array(
+ 'columns' => array('status'),
+ ),
+ 'ownerPHID' => array(
+ 'columns' => array('ownerPHID', 'status'),
+ ),
+ 'authorPHID' => array(
+ 'columns' => array('authorPHID', 'status'),
+ ),
+ 'ownerOrdering' => array(
+ 'columns' => array('ownerOrdering'),
+ ),
+ 'priority_2' => array(
+ 'columns' => array('priority', 'subpriority'),
+ ),
+ 'key_dateCreated' => array(
+ 'columns' => array('dateCreated'),
+ ),
+ 'key_dateModified' => array(
+ 'columns' => array('dateModified'),
+ ),
+ ),
) + parent::getConfiguration();
}
diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
--- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
+++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
@@ -113,6 +113,11 @@
'contentSource' => 'text',
'transactionType' => 'text32',
),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_object' => array(
+ 'columns' => array('objectPHID'),
+ ),
+ ),
) + parent::getConfiguration();
}
diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php b/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php
--- a/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php
+++ b/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php
@@ -38,6 +38,7 @@
self::CONFIG_KEY_SCHEMA => array(
'key_version' => array(
'columns' => array('transactionPHID', 'commentVersion'),
+ 'unique' => true,
),
),
) + parent::getConfiguration();
diff --git a/src/infrastructure/customfield/storage/PhabricatorCustomFieldNumericIndexStorage.php b/src/infrastructure/customfield/storage/PhabricatorCustomFieldNumericIndexStorage.php
--- a/src/infrastructure/customfield/storage/PhabricatorCustomFieldNumericIndexStorage.php
+++ b/src/infrastructure/customfield/storage/PhabricatorCustomFieldNumericIndexStorage.php
@@ -3,6 +3,23 @@
abstract class PhabricatorCustomFieldNumericIndexStorage
extends PhabricatorCustomFieldIndexStorage {
+ public function getConfiguration() {
+ return array(
+ self::CONFIG_COLUMN_SCHEMA => array(
+ 'indexKey' => 'bytes12',
+ 'indexValue' => 'sint64',
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_join' => array(
+ 'columns' => array('objectPHID', 'indexKey', 'indexValue'),
+ ),
+ 'key_find' => array(
+ 'columns' => array('indexKey', 'indexValue'),
+ ),
+ ),
+ ) + parent::getConfiguration();
+ }
+
public function formatForInsert(AphrontDatabaseConnection $conn) {
return qsprintf(
$conn,
diff --git a/src/infrastructure/customfield/storage/PhabricatorCustomFieldStorage.php b/src/infrastructure/customfield/storage/PhabricatorCustomFieldStorage.php
--- a/src/infrastructure/customfield/storage/PhabricatorCustomFieldStorage.php
+++ b/src/infrastructure/customfield/storage/PhabricatorCustomFieldStorage.php
@@ -10,6 +10,16 @@
public function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
+ self::CONFIG_COLUMN_SCHEMA => array(
+ 'fieldIndex' => 'bytes12',
+ 'fieldValue' => 'text',
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'objectPHID' => array(
+ 'columns' => array('objectPHID', 'fieldIndex'),
+ 'unique' => true,
+ ),
+ ),
) + parent::getConfiguration();
}
diff --git a/src/infrastructure/customfield/storage/PhabricatorCustomFieldStringIndexStorage.php b/src/infrastructure/customfield/storage/PhabricatorCustomFieldStringIndexStorage.php
--- a/src/infrastructure/customfield/storage/PhabricatorCustomFieldStringIndexStorage.php
+++ b/src/infrastructure/customfield/storage/PhabricatorCustomFieldStringIndexStorage.php
@@ -3,6 +3,23 @@
abstract class PhabricatorCustomFieldStringIndexStorage
extends PhabricatorCustomFieldIndexStorage {
+ public function getConfiguration() {
+ return array(
+ self::CONFIG_COLUMN_SCHEMA => array(
+ 'indexKey' => 'bytes12',
+ 'indexValue' => 'text',
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_join' => array(
+ 'columns' => array('objectPHID', 'indexKey', 'indexValue(64)'),
+ ),
+ 'key_find' => array(
+ 'columns' => array('indexKey', 'indexValue(64)'),
+ ),
+ ),
+ ) + parent::getConfiguration();
+ }
+
public function formatForInsert(AphrontDatabaseConnection $conn) {
return qsprintf(
$conn,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 5:10 AM (6 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705958
Default Alt Text
D10526.id.diff (15 KB)
Attached To
Mode
D10526: Generate expected schemata for Maniphest
Attached
Detach File
Event Timeline
Log In to Comment