From b0e145f2fe00194410bd199cc2396fcbfe6814f6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 16 Sep 2013 21:06:41 +0000 Subject: [PATCH] Provide generalized custom field storage and custom field indexes in Maniphest Summary: Ref T418. Depends on D6992. This adds index and value storage for Maniphest custom fields. Test Plan: Ran storage upgrade. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T418 Differential Revision: https://secure.phabricator.com/D6995 --- src/__phutil_library_map__.php | 6 ++++++ resources/sql/patches/20130915.maniphestcustom.sql | 29 +++++++++++++++++++++++++++++ src/applications/maniphest/field/ManiphestCustomField.php | 12 ++++++++++++ src/applications/maniphest/storage/ManiphestCustomFieldNumericIndex.php | 11 +++++++++++ src/applications/maniphest/storage/ManiphestCustomFieldStorage.php | 11 +++++++++++ src/applications/maniphest/storage/ManiphestCustomFieldStringIndex.php | 11 +++++++++++ src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php | 4 ++++ 7 file(s) changed, 84 insertion(s)(+), 0 deletion(s)(-) 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 @@ -691,6 +691,9 @@ 'ManiphestController' => 'applications/maniphest/controller/ManiphestController.php', 'ManiphestCreateMailReceiver' => 'applications/maniphest/mail/ManiphestCreateMailReceiver.php', 'ManiphestCustomField' => 'applications/maniphest/field/ManiphestCustomField.php', + 'ManiphestCustomFieldNumericIndex' => 'applications/maniphest/storage/ManiphestCustomFieldNumericIndex.php', + 'ManiphestCustomFieldStorage' => 'applications/maniphest/storage/ManiphestCustomFieldStorage.php', + 'ManiphestCustomFieldStringIndex' => 'applications/maniphest/storage/ManiphestCustomFieldStringIndex.php', 'ManiphestDAO' => 'applications/maniphest/storage/ManiphestDAO.php', 'ManiphestDefaultTaskExtensions' => 'applications/maniphest/extensions/ManiphestDefaultTaskExtensions.php', 'ManiphestEdgeEventListener' => 'applications/maniphest/event/ManiphestEdgeEventListener.php', @@ -2755,6 +2758,9 @@ 'ManiphestController' => 'PhabricatorController', 'ManiphestCreateMailReceiver' => 'PhabricatorMailReceiver', 'ManiphestCustomField' => 'PhabricatorCustomField', + 'ManiphestCustomFieldNumericIndex' => 'PhabricatorCustomFieldNumericIndexStorage', + 'ManiphestCustomFieldStorage' => 'PhabricatorCustomFieldStorage', + 'ManiphestCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage', 'ManiphestDAO' => 'PhabricatorLiskDAO', 'ManiphestDefaultTaskExtensions' => 'ManiphestTaskExtensions', 'ManiphestEdgeEventListener' => 'PhutilEventListener', diff --git a/resources/sql/patches/20130915.maniphestcustom.sql b/resources/sql/patches/20130915.maniphestcustom.sql new file mode 100644 --- /dev/null +++ b/resources/sql/patches/20130915.maniphestcustom.sql @@ -0,0 +1,29 @@ +CREATE TABLE {$NAMESPACE}_maniphest.maniphest_customfieldstorage ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + objectPHID VARCHAR(64) NOT NULL COLLATE utf8_bin, + fieldIndex CHAR(12) NOT NULL COLLATE utf8_bin, + fieldValue LONGTEXT NOT NULL, + UNIQUE KEY (objectPHID, fieldIndex) +) ENGINE=InnoDB, COLLATE utf8_general_ci; + +CREATE TABLE {$NAMESPACE}_maniphest.maniphest_customfieldstringindex ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + objectPHID VARCHAR(64) NOT NULL COLLATE utf8_bin, + indexKey VARCHAR(12) NOT NULL COLLATE utf8_bin, + indexValue LONGTEXT NOT NULL COLLATE utf8_general_ci, + + KEY `key_join` (objectPHID, indexKey, indexValue(64)), + KEY `key_find` (indexKey, indexValue(64)) + +) ENGINE=InnoDB, COLLATE utf8_general_ci; + +CREATE TABLE {$NAMESPACE}_maniphest.maniphest_customfieldnumericindex ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + objectPHID VARCHAR(64) NOT NULL COLLATE utf8_bin, + indexKey VARCHAR(12) NOT NULL COLLATE utf8_bin, + indexValue BIGINT NOT NULL, + + KEY `key_join` (objectPHID, indexKey, indexValue), + KEY `key_find` (indexKey, indexValue) + +) ENGINE=InnoDB, COLLATE utf8_general_ci; diff --git a/src/applications/maniphest/field/ManiphestCustomField.php b/src/applications/maniphest/field/ManiphestCustomField.php --- a/src/applications/maniphest/field/ManiphestCustomField.php +++ b/src/applications/maniphest/field/ManiphestCustomField.php @@ -3,4 +3,16 @@ abstract class ManiphestCustomField extends PhabricatorCustomField { + public function newStorageObject() { + return new ManiphestCustomFieldStorage(); + } + + protected function newStringIndexStorage() { + return new ManiphestCustomFieldStringIndex(); + } + + protected function newNumericIndexStorage() { + return new ManiphestCustomFieldNumericIndex(); + } + } diff --git a/src/applications/maniphest/storage/ManiphestCustomFieldNumericIndex.php b/src/applications/maniphest/storage/ManiphestCustomFieldNumericIndex.php new file mode 100644 --- /dev/null +++ b/src/applications/maniphest/storage/ManiphestCustomFieldNumericIndex.php @@ -0,0 +1,11 @@ + 'sql', 'name' => $this->getPatchPath('20130914.usercustom.sql'), ), + '20130915.maniphestcustom.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20130915.maniphestcustom.sql'), + ), ); } } -- tangled.sh