diff --git a/resources/sql/autopatches/20170915.ref.02.drop.id.sql b/resources/sql/autopatches/20170915.ref.02.drop.id.sql new file mode 100644 index 0000000000..177fde3b6a --- /dev/null +++ b/resources/sql/autopatches/20170915.ref.02.drop.id.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_repository.repository_refcursor + DROP COLUMN commitIdentifier; diff --git a/resources/sql/autopatches/20170915.ref.03.drop.closed.sql b/resources/sql/autopatches/20170915.ref.03.drop.closed.sql new file mode 100644 index 0000000000..927ee04b65 --- /dev/null +++ b/resources/sql/autopatches/20170915.ref.03.drop.closed.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_repository.repository_refcursor + DROP COLUMN isClosed; diff --git a/resources/sql/autopatches/20170915.ref.04.uniq.sql b/resources/sql/autopatches/20170915.ref.04.uniq.sql new file mode 100644 index 0000000000..0bef69fc4a --- /dev/null +++ b/resources/sql/autopatches/20170915.ref.04.uniq.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_repository.repository_refcursor + ADD UNIQUE KEY `key_ref` (repositoryPHID, refType, refNameHash); diff --git a/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php b/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php index febbed3ee6..ec0c90744c 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php +++ b/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php @@ -1,99 +1,96 @@ false, self::CONFIG_AUX_PHID => true, self::CONFIG_BINARY => array( 'refNameRaw' => true, ), self::CONFIG_COLUMN_SCHEMA => array( 'refType' => 'text32', 'refNameHash' => 'bytes12', - 'commitIdentifier' => 'text40', 'refNameEncoding' => 'text16?', - 'isClosed' => 'bool', ), self::CONFIG_KEY_SCHEMA => array( - 'key_cursor' => array( + 'key_ref' => array( 'columns' => array('repositoryPHID', 'refType', 'refNameHash'), + 'unique' => true, ), ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhabricatorRepositoryRefCursorPHIDType::TYPECONST); } public function getRefName() { return $this->getUTF8StringFromStorage( $this->getRefNameRaw(), $this->getRefNameEncoding()); } public function setRefName($ref_raw) { $this->setRefNameRaw($ref_raw); $this->setRefNameHash(PhabricatorHash::digestForIndex($ref_raw)); $this->setRefNameEncoding($this->detectEncodingForStorage($ref_raw)); return $this; } public function attachRepository(PhabricatorRepository $repository) { $this->repository = $repository; return $this; } public function getRepository() { return $this->assertAttached($this->repository); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, ); } public function getPolicy($capability) { return $this->getRepository()->getPolicy($capability); } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return $this->getRepository()->hasAutomaticCapability($capability, $viewer); } public function describeAutomaticCapability($capability) { return pht('Repository refs have the same policies as their repository.'); } }