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 @@ -138,6 +138,10 @@ 'src' => array( 'columns' => array('src', 'type', 'dateCreated', 'seq'), ), + 'key_dst' => array( + 'columns' => array('dst', 'type', 'src'), + 'unique' => true, + ), )); $this->buildRawSchema( @@ -251,16 +255,24 @@ $charset = 'binary'; $collation = 'binary'; break; + case 'bytes20': + $column_type = 'char(20)'; + $charset = 'binary'; + $collation = 'binary'; + break; case 'bytes12': $column_type = 'char(12)'; $charset = 'binary'; $collation = 'binary'; break; - case 'bytes': - $column_type = 'longblob'; + case 'bytes4': + $column_type = 'char(4)'; $charset = 'binary'; $collation = 'binary'; break; + case 'bytes': + $column_type = 'longblob'; + break; case 'text255': $column_type = 'varchar(255)'; $charset = $this->getUTF8Charset(); diff --git a/src/applications/differential/storage/DifferentialAffectedPath.php b/src/applications/differential/storage/DifferentialAffectedPath.php --- a/src/applications/differential/storage/DifferentialAffectedPath.php +++ b/src/applications/differential/storage/DifferentialAffectedPath.php @@ -14,6 +14,18 @@ public function getConfiguration() { return array( self::CONFIG_TIMESTAMPS => false, + self::CONFIG_COLUMN_SCHEMA => array( + 'id' => null, + ), + self::CONFIG_KEY_SCHEMA => array( + 'PRIMARY' => null, + 'repositoryID' => array( + 'columns' => array('repositoryID', 'pathID', 'epoch'), + ), + 'revisionID' => array( + 'columns' => array('revisionID'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/differential/storage/DifferentialChangeset.php b/src/applications/differential/storage/DifferentialChangeset.php --- a/src/applications/differential/storage/DifferentialChangeset.php +++ b/src/applications/differential/storage/DifferentialChangeset.php @@ -28,7 +28,21 @@ 'oldProperties' => self::SERIALIZATION_JSON, 'newProperties' => self::SERIALIZATION_JSON, 'awayPaths' => self::SERIALIZATION_JSON, - )) + parent::getConfiguration(); + ), + self::CONFIG_COLUMN_SCHEMA => array( + 'oldFile' => 'text255?', + 'filename' => 'text255', + 'changeType' => 'uint32', + 'fileType' => 'uint32', + 'addLines' => 'uint32', + 'delLines' => 'uint32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'diffID' => array( + 'columns' => array('diffID'), + ), + ), + ) + parent::getConfiguration(); } public function getAffectedLineCount() { diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php --- a/src/applications/differential/storage/DifferentialDiff.php +++ b/src/applications/differential/storage/DifferentialDiff.php @@ -42,6 +42,30 @@ public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, + self::CONFIG_COLUMN_SCHEMA => array( + 'revisionID' => 'id?', + 'authorPHID' => 'phid?', + 'repositoryPHID' => 'phid?', + 'sourceMachine' => 'text255?', + 'sourcePath' => 'text255?', + 'sourceControlSystem' => 'text64?', + 'sourceControlBaseRevision' => 'text255?', + 'sourceControlPath' => 'text255?', + 'lintStatus' => 'uint32', + 'unitStatus' => 'uint32', + 'lineCount' => 'uint32', + 'branch' => 'text255?', + 'bookmark' => 'text255?', + 'arcanistProjectPHID' => 'phid?', + 'creationMethod' => 'text255', + 'description' => 'text255', + 'repositoryUUID' => 'text64?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'revisionID' => array( + 'columns' => array('revisionID'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/differential/storage/DifferentialDiffProperty.php b/src/applications/differential/storage/DifferentialDiffProperty.php --- a/src/applications/differential/storage/DifferentialDiffProperty.php +++ b/src/applications/differential/storage/DifferentialDiffProperty.php @@ -10,7 +10,17 @@ return array( self::CONFIG_SERIALIZATION => array( 'data' => self::SERIALIZATION_JSON, - )) + parent::getConfiguration(); + ), + self::CONFIG_COLUMN_SCHEMA => array( + 'name' => 'text255', + ), + self::CONFIG_KEY_SCHEMA => array( + 'diffID' => array( + 'columns' => array('diffID', 'name'), + 'unique' => true, + ), + ), + ) + parent::getConfiguration(); } } diff --git a/src/applications/differential/storage/DifferentialDraft.php b/src/applications/differential/storage/DifferentialDraft.php --- a/src/applications/differential/storage/DifferentialDraft.php +++ b/src/applications/differential/storage/DifferentialDraft.php @@ -6,6 +6,20 @@ protected $authorPHID; protected $draftKey; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'draftKey' => 'text64', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_unique' => array( + 'columns' => array('objectPHID', 'authorPHID', 'draftKey'), + 'unique' => true, + ), + ), + ) + parent::getConfiguration(); + } + public static function markHasDraft( $author_phid, $object_phid, diff --git a/src/applications/differential/storage/DifferentialHunkLegacy.php b/src/applications/differential/storage/DifferentialHunkLegacy.php --- a/src/applications/differential/storage/DifferentialHunkLegacy.php +++ b/src/applications/differential/storage/DifferentialHunkLegacy.php @@ -4,6 +4,23 @@ protected $changes; + public function getConfiguration() { + return array( + self::CONFIG_COLUMN_SCHEMA => array( + 'changes' => 'text?', + 'oldOffset' => 'uint32', + 'oldLen' => 'uint32', + 'newOffset' => 'uint32', + 'newLen' => 'uint32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'changesetID' => array( + 'columns' => array('changesetID'), + ), + ), + ) + parent::getConfiguration(); + } + public function getTableName() { return 'differential_hunk'; } diff --git a/src/applications/differential/storage/DifferentialHunkModern.php b/src/applications/differential/storage/DifferentialHunkModern.php --- a/src/applications/differential/storage/DifferentialHunkModern.php +++ b/src/applications/differential/storage/DifferentialHunkModern.php @@ -25,6 +25,23 @@ self::CONFIG_BINARY => array( 'data' => true, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'dataType' => 'bytes4', + 'dataEncoding' => 'text16?', + 'dataFormat' => 'bytes4', + 'oldOffset' => 'uint32', + 'oldLen' => 'uint32', + 'newOffset' => 'uint32', + 'newLen' => 'uint32', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_changeset' => array( + 'columns' => array('changesetID'), + ), + 'key_created' => array( + 'columns' => array('dateCreated'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php --- a/src/applications/differential/storage/DifferentialRevision.php +++ b/src/applications/differential/storage/DifferentialRevision.php @@ -74,6 +74,33 @@ 'attached' => self::SERIALIZATION_JSON, 'unsubscribed' => self::SERIALIZATION_JSON, ), + self::CONFIG_COLUMN_SCHEMA => array( + 'title' => 'text255', + 'originalTitle' => 'text255', + 'status' => 'text32', + 'summary' => 'text', + 'testPlan' => 'text', + 'authorPHID' => 'phid?', + 'lastReviewerPHID' => 'phid?', + 'lineCount' => 'uint32?', + 'mailKey' => 'bytes40', + 'branchName' => 'text255', + 'arcanistProjectPHID' => 'phid?', + 'repositoryPHID' => 'phid?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_phid' => null, + 'phid' => array( + 'columns' => array('phid'), + 'unique' => true, + ), + 'authorPHID' => array( + 'columns' => array('authorPHID', 'status'), + ), + 'repositoryPHID' => array( + 'columns' => array('repositoryPHID'), + ), + ), ) + parent::getConfiguration(); } diff --git a/src/applications/differential/storage/DifferentialSchemaSpec.php b/src/applications/differential/storage/DifferentialSchemaSpec.php --- a/src/applications/differential/storage/DifferentialSchemaSpec.php +++ b/src/applications/differential/storage/DifferentialSchemaSpec.php @@ -4,7 +4,74 @@ public function buildSchemata() { $this->buildLiskSchemata('DifferentialDAO'); -// $this->addEdgeSchemata($server, new DifferentialRevision()); + + $this->buildEdgeSchemata(new DifferentialRevision()); + + $this->buildTransactionSchema( + new DifferentialTransaction(), + new DifferentialTransactionComment()); + + $this->buildCustomFieldSchemata( + new DifferentialCustomFieldStorage(), + array( + new DifferentialCustomFieldNumericIndex(), + new DifferentialCustomFieldStringIndex(), + )); + + $this->buildRawSchema( + id(new DifferentialRevision())->getApplicationName(), + DifferentialChangeset::TABLE_CACHE, + array( + 'id' => 'id', + 'cache' => 'bytes', + 'dateCreated' => 'epoch', + ), + array( + 'PRIMARY' => array( + 'columns' => array('id'), + 'unique' => true, + ), + 'dateCreated' => array( + 'columns' => array('dateCreated'), + ), + )); + + $this->buildRawSchema( + id(new DifferentialRevision())->getApplicationName(), + DifferentialRevision::TABLE_COMMIT, + array( + 'revisionID' => 'id', + 'commitPHID' => 'phid', + ), + array( + 'PRIMARY' => array( + 'columns' => array('revisionID', 'commitPHID'), + 'unique' => true, + ), + 'commitPHID' => array( + 'columns' => array('commitPHID'), + 'unique' => true, + ), + )); + + $this->buildRawSchema( + id(new DifferentialRevision())->getApplicationName(), + ArcanistDifferentialRevisionHash::TABLE_NAME, + array( + 'revisionID' => 'id', + 'type' => 'bytes4', + 'hash' => 'bytes40', + ), + array( + 'type' => array( + 'columns' => array('type', 'hash'), + ), + 'revisionID' => array( + 'columns' => array('revisionID'), + ), + )); + + } } diff --git a/src/applications/differential/storage/DifferentialTransactionComment.php b/src/applications/differential/storage/DifferentialTransactionComment.php --- a/src/applications/differential/storage/DifferentialTransactionComment.php +++ b/src/applications/differential/storage/DifferentialTransactionComment.php @@ -16,6 +16,32 @@ return new DifferentialTransaction(); } + public function getConfiguration() { + $config = parent::getConfiguration(); + $config[self::CONFIG_COLUMN_SCHEMA] = array( + 'revisionPHID' => 'phid?', + 'changesetID' => 'id?', + 'isNewFile' => 'bool', + 'lineNumber' => 'uint32', + 'lineLength' => 'uint32', + 'fixedState' => 'text12?', + 'hasReplies' => 'bool', + 'replyToCommentPHID' => 'phid?', + ) + $config[self::CONFIG_COLUMN_SCHEMA]; + $config[self::CONFIG_KEY_SCHEMA] = array( + 'key_draft' => array( + 'columns' => array('authorPHID', 'transactionPHID'), + ), + 'key_changeset' => array( + 'columns' => array('changesetID'), + ), + 'key_revision' => array( + 'columns' => array('revisionPHID'), + ), + ) + $config[self::CONFIG_KEY_SCHEMA]; + return $config; + } + public function shouldUseMarkupCache($field) { // Only cache submitted comments. return ($this->getTransactionPHID() != null);