From 5ff0ae7d48a7b9d59e7cd58ae1ebe1ca928dba15 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 28 Apr 2020 13:38:46 -0700 Subject: [PATCH] Add generic "attributes" storage to inline comment tables Summary: Ref T13513. This plans for "currently editing", character range comments, code suggestions, document engine tracking. And absolutely nothing else. Test Plan: - Ran `bin/storage upgrade -f`, got a clean upgrade. - Created and submitted some inline comments; nothing exploded. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21184 --- .../20200428.inline.01.differential.column.sql | 2 ++ .../autopatches/20200428.inline.02.diffusion.column.sql | 2 ++ .../autopatches/20200428.inline.03.differential.value.sql | 2 ++ .../autopatches/20200428.inline.04.diffusion.value.sql | 2 ++ .../audit/storage/PhabricatorAuditTransactionComment.php | 5 +++++ .../storage/DifferentialTransactionComment.php | 8 ++++++++ 6 files changed, 21 insertions(+) create mode 100644 resources/sql/autopatches/20200428.inline.01.differential.column.sql create mode 100644 resources/sql/autopatches/20200428.inline.02.diffusion.column.sql create mode 100644 resources/sql/autopatches/20200428.inline.03.differential.value.sql create mode 100644 resources/sql/autopatches/20200428.inline.04.diffusion.value.sql diff --git a/resources/sql/autopatches/20200428.inline.01.differential.column.sql b/resources/sql/autopatches/20200428.inline.01.differential.column.sql new file mode 100644 index 0000000000..d825565000 --- /dev/null +++ b/resources/sql/autopatches/20200428.inline.01.differential.column.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_differential.differential_transaction_comment + ADD attributes LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}; diff --git a/resources/sql/autopatches/20200428.inline.02.diffusion.column.sql b/resources/sql/autopatches/20200428.inline.02.diffusion.column.sql new file mode 100644 index 0000000000..ac567b9a8e --- /dev/null +++ b/resources/sql/autopatches/20200428.inline.02.diffusion.column.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_audit.audit_transaction_comment + ADD attributes LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}; diff --git a/resources/sql/autopatches/20200428.inline.03.differential.value.sql b/resources/sql/autopatches/20200428.inline.03.differential.value.sql new file mode 100644 index 0000000000..dfa420a8ac --- /dev/null +++ b/resources/sql/autopatches/20200428.inline.03.differential.value.sql @@ -0,0 +1,2 @@ +UPDATE {$NAMESPACE}_differential.differential_transaction_comment + SET attributes = '{}' WHERE attributes = ''; diff --git a/resources/sql/autopatches/20200428.inline.04.diffusion.value.sql b/resources/sql/autopatches/20200428.inline.04.diffusion.value.sql new file mode 100644 index 0000000000..3fb10d7f2b --- /dev/null +++ b/resources/sql/autopatches/20200428.inline.04.diffusion.value.sql @@ -0,0 +1,2 @@ +UPDATE {$NAMESPACE}_audit.audit_transaction_comment + SET attributes = '{}' WHERE attributes = ''; diff --git a/src/applications/audit/storage/PhabricatorAuditTransactionComment.php b/src/applications/audit/storage/PhabricatorAuditTransactionComment.php index 64ddca8e25..bc4b1e675b 100644 --- a/src/applications/audit/storage/PhabricatorAuditTransactionComment.php +++ b/src/applications/audit/storage/PhabricatorAuditTransactionComment.php @@ -12,6 +12,7 @@ final class PhabricatorAuditTransactionComment protected $hasReplies = 0; protected $replyToCommentPHID; protected $legacyCommentID; + protected $attributes = array(); private $replyToComment = self::ATTACHABLE; @@ -54,6 +55,10 @@ final class PhabricatorAuditTransactionComment ), ) + $config[self::CONFIG_KEY_SCHEMA]; + $config[self::CONFIG_SERIALIZATION] = array( + 'attributes' => self::SERIALIZATION_JSON, + ) + idx($config, self::CONFIG_SERIALIZATION, array()); + return $config; } diff --git a/src/applications/differential/storage/DifferentialTransactionComment.php b/src/applications/differential/storage/DifferentialTransactionComment.php index d2ec6acc43..b2c24c340c 100644 --- a/src/applications/differential/storage/DifferentialTransactionComment.php +++ b/src/applications/differential/storage/DifferentialTransactionComment.php @@ -11,6 +11,7 @@ final class DifferentialTransactionComment protected $fixedState; protected $hasReplies = 0; protected $replyToCommentPHID; + protected $attributes = array(); private $replyToComment = self::ATTACHABLE; private $isHidden = self::ATTACHABLE; @@ -32,6 +33,7 @@ final class DifferentialTransactionComment protected function getConfiguration() { $config = parent::getConfiguration(); + $config[self::CONFIG_COLUMN_SCHEMA] = array( 'revisionPHID' => 'phid?', 'changesetID' => 'id?', @@ -42,6 +44,7 @@ final class DifferentialTransactionComment 'hasReplies' => 'bool', 'replyToCommentPHID' => 'phid?', ) + $config[self::CONFIG_COLUMN_SCHEMA]; + $config[self::CONFIG_KEY_SCHEMA] = array( 'key_draft' => array( 'columns' => array('authorPHID', 'transactionPHID'), @@ -53,6 +56,11 @@ final class DifferentialTransactionComment 'columns' => array('revisionPHID'), ), ) + $config[self::CONFIG_KEY_SCHEMA]; + + $config[self::CONFIG_SERIALIZATION] = array( + 'attributes' => self::SERIALIZATION_JSON, + ) + idx($config, self::CONFIG_SERIALIZATION, array()); + return $config; }