@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Generate expected schemata for Maniphest

Summary:
Ref T1191.

- Adds support for custom fields.
- Adds support for partial indexes (indexes on a prefix of a column).
- Drops old auxiliary storage table: this was moved to custom field storage about a year ago.
- Drops old project table: this was moved to edges about two months ago.

Test Plan:
- Viewed web UI, saw fewer issues.
- Used `grep` to verify no readers/writers for storage or project table.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1191

Differential Revision: https://secure.phabricator.com/D10526

+207 -7
+1
resources/sql/autopatches/20140919.schema.03.dropaux.sql
··· 1 + DROP TABLE {$NAMESPACE}_maniphest.maniphest_taskauxiliarystorage;
+1
resources/sql/autopatches/20140919.schema.04.droptaskproj.sql
··· 1 + DROP TABLE {$NAMESPACE}_maniphest.maniphest_taskproject;
+2
src/__phutil_library_map__.php
··· 918 918 'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php', 919 919 'ManiphestReplyHandler' => 'applications/maniphest/mail/ManiphestReplyHandler.php', 920 920 'ManiphestReportController' => 'applications/maniphest/controller/ManiphestReportController.php', 921 + 'ManiphestSchemaSpec' => 'applications/maniphest/storage/ManiphestSchemaSpec.php', 921 922 'ManiphestSearchIndexer' => 'applications/maniphest/search/ManiphestSearchIndexer.php', 922 923 'ManiphestStatusConfigOptionType' => 'applications/maniphest/config/ManiphestStatusConfigOptionType.php', 923 924 'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php', ··· 3800 3801 'ManiphestRemarkupRule' => 'PhabricatorObjectRemarkupRule', 3801 3802 'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler', 3802 3803 'ManiphestReportController' => 'ManiphestController', 3804 + 'ManiphestSchemaSpec' => 'PhabricatorConfigSchemaSpec', 3803 3805 'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 3804 3806 'ManiphestStatusConfigOptionType' => 'PhabricatorConfigJSONOptionType', 3805 3807 'ManiphestSubpriorityController' => 'ManiphestController',
+7 -3
src/applications/config/controller/PhabricatorConfigDatabaseStatusController.php
··· 280 280 $collation_issue = PhabricatorConfigStorageSchema::ISSUE_COLLATION; 281 281 $nullable_issue = PhabricatorConfigStorageSchema::ISSUE_NULLABLE; 282 282 $unique_issue = PhabricatorConfigStorageSchema::ISSUE_UNIQUE; 283 + $columns_issue = PhabricatorConfigStorageSchema::ISSUE_KEYCOLUMNS; 283 284 284 285 $database = $comp->getDatabase($database_name); 285 286 if (!$database) { ··· 377 378 $status = $key->getStatus(); 378 379 379 380 $size = 0; 380 - foreach ($key->getColumnNames() as $column_name) { 381 + foreach ($key->getColumnNames() as $column_spec) { 382 + list($column_name, $prefix) = $key->getKeyColumnAndPrefix($column_spec); 381 383 $column = $table->getColumn($column_name); 382 384 if (!$column) { 383 385 $size = 0; 384 386 break; 385 387 } 386 - $size += $column->getKeyByteLength(); 388 + $size += $column->getKeyByteLength($prefix); 387 389 } 388 390 389 391 $size_formatted = null; ··· 406 408 $key_name.'/'), 407 409 ), 408 410 $key_name), 409 - implode(', ', $key->getColumnNames()), 411 + $this->renderAttr( 412 + implode(', ', $key->getColumnNames()), 413 + $key->hasIssue($columns_issue)), 410 414 $this->renderAttr( 411 415 $this->renderBoolean($key->getUnique()), 412 416 $key->hasIssue($unique_issue)),
+30 -3
src/applications/config/schema/PhabricatorConfigColumnSchema.php
··· 58 58 return $this->characterSet; 59 59 } 60 60 61 - public function getKeyByteLength() { 61 + public function getKeyByteLength($prefix = null) { 62 62 $type = $this->getColumnType(); 63 63 64 64 $matches = null; 65 65 if (preg_match('/^varchar\((\d+)\)$/', $type, $matches)) { 66 66 // For utf8mb4, each character requires 4 bytes. 67 - return ((int)$matches[1]) * 4; 67 + $size = (int)$matches[1]; 68 + if ($prefix && $prefix < $size) { 69 + $size = $prefix; 70 + } 71 + return $size * 4; 68 72 } 69 73 70 74 $matches = null; 71 75 if (preg_match('/^char\((\d+)\)$/', $type, $matches)) { 72 76 // We use char() only for fixed-length binary data, so its size 73 77 // is always the column size. 74 - return ((int)$matches[1]); 78 + $size = (int)$matches[1]; 79 + if ($prefix && $prefix < $size) { 80 + $size = $prefix; 81 + } 82 + return $size; 83 + } 84 + 85 + // The "long..." types are arbitrarily long, so just use a big number to 86 + // get the point across. In practice, these should always index only a 87 + // prefix. 88 + if ($type == 'longtext') { 89 + $size = (1 << 16); 90 + if ($prefix && $prefix < $size) { 91 + $size = $prefix; 92 + } 93 + return $size * 4; 94 + } 95 + 96 + if ($type == 'longblob') { 97 + $size = (1 << 16); 98 + if ($prefix && $prefix < $size) { 99 + $size = $prefix; 100 + } 101 + return $size * 1; 75 102 } 76 103 77 104 switch ($type) {
+9
src/applications/config/schema/PhabricatorConfigKeySchema.php
··· 28 28 return array(); 29 29 } 30 30 31 + public function getKeyColumnAndPrefix($column_name) { 32 + $matches = null; 33 + if (preg_match('/^(.*)\((\d+)\)\z/', $column_name, $matches)) { 34 + return array($matches[1], (int)$matches[2]); 35 + } else { 36 + return array($column_name, null); 37 + } 38 + } 39 + 31 40 public function compareToSimilarSchema( 32 41 PhabricatorConfigStorageSchema $expect) { 33 42
+12 -1
src/applications/config/schema/PhabricatorConfigSchemaQuery.php
··· 115 115 foreach ($keys as $key_name => $key_pieces) { 116 116 $key_pieces = isort($key_pieces, 'Seq_in_index'); 117 117 $head = head($key_pieces); 118 + 119 + // This handles string indexes which index only a prefix of a field. 120 + $column_names = array(); 121 + foreach ($key_pieces as $piece) { 122 + $name = $piece['Column_name']; 123 + if ($piece['Sub_part']) { 124 + $name = $name.'('.$piece['Sub_part'].')'; 125 + } 126 + $column_names[] = $name; 127 + } 128 + 118 129 $key_schema = id(new PhabricatorConfigKeySchema()) 119 130 ->setName($key_name) 120 - ->setColumnNames(ipull($key_pieces, 'Column_name')) 131 + ->setColumnNames($column_names) 121 132 ->setUnique(!$head['Non_unique']); 122 133 123 134 $table_schema->addKey($key_schema);
+18
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
··· 56 56 } 57 57 } 58 58 59 + protected function buildCustomFieldSchemata( 60 + PhabricatorLiskDAO $storage, 61 + array $indexes) { 62 + 63 + $this->buildLiskObjectSchema($storage); 64 + foreach ($indexes as $index) { 65 + $this->buildLiskObjectSchema($index); 66 + } 67 + } 68 + 59 69 private function buildLiskObjectSchema(PhabricatorLiskDAO $object) { 60 70 $this->buildRawSchema( 61 71 $object->getApplicationName(), ··· 123 133 array( 124 134 'PRIMARY' => array( 125 135 'columns' => array('src', 'type', 'dst'), 136 + 'unique' => true, 137 + ), 138 + 'src' => array( 139 + 'columns' => array('src', 'type', 'dateCreated', 'seq'), 126 140 ), 127 141 )); 128 142 ··· 136 150 array( 137 151 'PRIMARY' => array( 138 152 'columns' => array('id'), 153 + 'unique' => true, 139 154 ), 140 155 )); 141 156 } ··· 216 231 case 'id64': 217 232 case 'uint64': 218 233 $column_type = 'bigint(20) unsigned'; 234 + break; 235 + case 'sint64': 236 + $column_type = 'bigint(20)'; 219 237 break; 220 238 case 'phid': 221 239 case 'policy';
+12
src/applications/maniphest/storage/ManiphestNameIndex.php
··· 12 12 public function getConfiguration() { 13 13 return array( 14 14 self::CONFIG_TIMESTAMPS => false, 15 + self::CONFIG_COLUMN_SCHEMA => array( 16 + 'indexedObjectName' => 'text128', 17 + ), 18 + self::CONFIG_KEY_SCHEMA => array( 19 + 'key_phid' => array( 20 + 'columns' => array('indexedObjectPHID'), 21 + 'unique' => true, 22 + ), 23 + 'key_name' => array( 24 + 'columns' => array('indexedObjectName'), 25 + ), 26 + ), 15 27 ) + parent::getConfiguration(); 16 28 } 17 29
+22
src/applications/maniphest/storage/ManiphestSchemaSpec.php
··· 1 + <?php 2 + 3 + final class ManiphestSchemaSpec 4 + extends PhabricatorConfigSchemaSpec { 5 + 6 + public function buildSchemata() { 7 + $this->buildLiskSchemata('ManiphestDAO'); 8 + 9 + $this->buildEdgeSchemata(new ManiphestTask()); 10 + $this->buildTransactionSchema( 11 + new ManiphestTransaction(), 12 + new ManiphestTransactionComment()); 13 + 14 + $this->buildCustomFieldSchemata( 15 + new ManiphestCustomFieldStorage(), 16 + array( 17 + new ManiphestCustomFieldNumericIndex(), 18 + new ManiphestCustomFieldStringIndex(), 19 + )); 20 + } 21 + 22 + }
+43
src/applications/maniphest/storage/ManiphestTask.php
··· 67 67 'attached' => self::SERIALIZATION_JSON, 68 68 'projectPHIDs' => self::SERIALIZATION_JSON, 69 69 ), 70 + self::CONFIG_COLUMN_SCHEMA => array( 71 + 'ownerPHID' => 'phid?', 72 + 'status' => 'text12', 73 + 'priority' => 'uint32', 74 + 'title' => 'text', 75 + 'originalTitle' => 'text', 76 + 'description' => 'text', 77 + 'mailKey' => 'bytes20', 78 + 'ownerOrdering' => 'text64?', 79 + 'originalEmailSource' => 'text255?', 80 + 'subpriority' => 'double', 81 + ), 82 + self::CONFIG_KEY_SCHEMA => array( 83 + 'key_phid' => null, 84 + 'phid' => array( 85 + 'columns' => array('phid'), 86 + 'unique' => true, 87 + ), 88 + 'priority' => array( 89 + 'columns' => array('priority', 'status'), 90 + ), 91 + 'status' => array( 92 + 'columns' => array('status'), 93 + ), 94 + 'ownerPHID' => array( 95 + 'columns' => array('ownerPHID', 'status'), 96 + ), 97 + 'authorPHID' => array( 98 + 'columns' => array('authorPHID', 'status'), 99 + ), 100 + 'ownerOrdering' => array( 101 + 'columns' => array('ownerOrdering'), 102 + ), 103 + 'priority_2' => array( 104 + 'columns' => array('priority', 'subpriority'), 105 + ), 106 + 'key_dateCreated' => array( 107 + 'columns' => array('dateCreated'), 108 + ), 109 + 'key_dateModified' => array( 110 + 'columns' => array('dateModified'), 111 + ), 112 + ), 70 113 ) + parent::getConfiguration(); 71 114 } 72 115
+5
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 113 113 'contentSource' => 'text', 114 114 'transactionType' => 'text32', 115 115 ), 116 + self::CONFIG_KEY_SCHEMA => array( 117 + 'key_object' => array( 118 + 'columns' => array('objectPHID'), 119 + ), 120 + ), 116 121 ) + parent::getConfiguration(); 117 122 } 118 123
+1
src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php
··· 38 38 self::CONFIG_KEY_SCHEMA => array( 39 39 'key_version' => array( 40 40 'columns' => array('transactionPHID', 'commentVersion'), 41 + 'unique' => true, 41 42 ), 42 43 ), 43 44 ) + parent::getConfiguration();
+17
src/infrastructure/customfield/storage/PhabricatorCustomFieldNumericIndexStorage.php
··· 3 3 abstract class PhabricatorCustomFieldNumericIndexStorage 4 4 extends PhabricatorCustomFieldIndexStorage { 5 5 6 + public function getConfiguration() { 7 + return array( 8 + self::CONFIG_COLUMN_SCHEMA => array( 9 + 'indexKey' => 'bytes12', 10 + 'indexValue' => 'sint64', 11 + ), 12 + self::CONFIG_KEY_SCHEMA => array( 13 + 'key_join' => array( 14 + 'columns' => array('objectPHID', 'indexKey', 'indexValue'), 15 + ), 16 + 'key_find' => array( 17 + 'columns' => array('indexKey', 'indexValue'), 18 + ), 19 + ), 20 + ) + parent::getConfiguration(); 21 + } 22 + 6 23 public function formatForInsert(AphrontDatabaseConnection $conn) { 7 24 return qsprintf( 8 25 $conn,
+10
src/infrastructure/customfield/storage/PhabricatorCustomFieldStorage.php
··· 10 10 public function getConfiguration() { 11 11 return array( 12 12 self::CONFIG_TIMESTAMPS => false, 13 + self::CONFIG_COLUMN_SCHEMA => array( 14 + 'fieldIndex' => 'bytes12', 15 + 'fieldValue' => 'text', 16 + ), 17 + self::CONFIG_KEY_SCHEMA => array( 18 + 'objectPHID' => array( 19 + 'columns' => array('objectPHID', 'fieldIndex'), 20 + 'unique' => true, 21 + ), 22 + ), 13 23 ) + parent::getConfiguration(); 14 24 } 15 25
+17
src/infrastructure/customfield/storage/PhabricatorCustomFieldStringIndexStorage.php
··· 3 3 abstract class PhabricatorCustomFieldStringIndexStorage 4 4 extends PhabricatorCustomFieldIndexStorage { 5 5 6 + public function getConfiguration() { 7 + return array( 8 + self::CONFIG_COLUMN_SCHEMA => array( 9 + 'indexKey' => 'bytes12', 10 + 'indexValue' => 'text', 11 + ), 12 + self::CONFIG_KEY_SCHEMA => array( 13 + 'key_join' => array( 14 + 'columns' => array('objectPHID', 'indexKey', 'indexValue(64)'), 15 + ), 16 + 'key_find' => array( 17 + 'columns' => array('indexKey', 'indexValue(64)'), 18 + ), 19 + ), 20 + ) + parent::getConfiguration(); 21 + } 22 + 6 23 public function formatForInsert(AphrontDatabaseConnection $conn) { 7 24 return qsprintf( 8 25 $conn,