1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Assign PHIDs to PushLogs

Summary: Ref T4195. We need these in Herald, since HeraldTranscripts need to refer to a PHID which they acted upon.

Test Plan:
Ran migration, got PHIDs:

  mysql> select phid from repository_pushlog limit 3;
  +--------------------------------+
  | phid                           |
  +--------------------------------+
  | PHID-PSHL-25jnc6cjgzw5rwqgmr7r |
  | PHID-PSHL-2vrvmtslkrj5yv7nxsv2 |
  | PHID-PSHL-34x262zkrwoka6mplony |
  +--------------------------------+
  3 rows in set (0.00 sec)

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4195

Differential Revision: https://secure.phabricator.com/D7780
This commit is contained in:
epriestley 2013-12-17 15:23:23 -08:00
parent 2216a5e6ef
commit f28d3089d7
7 changed files with 88 additions and 0 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_repository.repository_pushlog
ADD phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id;

View file

@ -0,0 +1,20 @@
<?php
$table = new PhabricatorRepositoryPushLog();
$conn_w = $table->establishConnection('w');
echo "Assigning PHIDs to push logs...\n";
$logs = new LiskMigrationIterator($table);
foreach ($logs as $log) {
$id = $log->getID();
echo "Updating {$id}...\n";
queryfx(
$conn_w,
'UPDATE %T SET phid = %s WHERE id = %d',
$table->getTableName(),
$log->generatePHID(),
$id);
}
echo "Done.\n";

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_repository.repository_pushlog
ADD UNIQUE KEY `key_phid` (phid);

View file

@ -1798,6 +1798,7 @@ phutil_register_library_map(array(
'PhabricatorRepositoryPHIDTypeArcanistProject' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeArcanistProject.php',
'PhabricatorRepositoryPHIDTypeCommit' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeCommit.php',
'PhabricatorRepositoryPHIDTypeMirror' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeMirror.php',
'PhabricatorRepositoryPHIDTypePushLog' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypePushLog.php',
'PhabricatorRepositoryPHIDTypeRepository' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php',
'PhabricatorRepositoryPullEngine' => 'applications/repository/engine/PhabricatorRepositoryPullEngine.php',
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php',
@ -4363,6 +4364,7 @@ phutil_register_library_map(array(
'PhabricatorRepositoryPHIDTypeArcanistProject' => 'PhabricatorPHIDType',
'PhabricatorRepositoryPHIDTypeCommit' => 'PhabricatorPHIDType',
'PhabricatorRepositoryPHIDTypeMirror' => 'PhabricatorPHIDType',
'PhabricatorRepositoryPHIDTypePushLog' => 'PhabricatorPHIDType',
'PhabricatorRepositoryPHIDTypeRepository' => 'PhabricatorPHIDType',
'PhabricatorRepositoryPullEngine' => 'PhabricatorRepositoryEngine',
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon',

View file

@ -0,0 +1,44 @@
<?php
final class PhabricatorRepositoryPHIDTypePushLog
extends PhabricatorPHIDType {
const TYPECONST = 'PSHL';
public function getTypeConstant() {
return self::TYPECONST;
}
public function getTypeName() {
return pht('Push Log');
}
public function newObject() {
return new PhabricatorRepositoryPushLog();
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new PhabricatorRepositoryPushLogQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$log = $objects[$phid];
$handle->setName(pht('Push Log %d', $log->getID()));
}
}
public function canLoadNamedObject($name) {
return false;
}
}

View file

@ -57,10 +57,16 @@ final class PhabricatorRepositoryPushLog
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_TIMESTAMPS => false,
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorRepositoryPHIDTypePushLog::TYPECONST);
}
public function attachRepository(PhabricatorRepository $repository) {
$this->repository = $repository;
return $this;

View file

@ -1832,6 +1832,18 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql',
'name' => $this->getPatchPath('20131211.phragmentedges.sql'),
),
'20131217.pushlogphid.1.col.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20131217.pushlogphid.1.col.sql'),
),
'20131217.pushlogphid.2.mig.php' => array(
'type' => 'php',
'name' => $this->getPatchPath('20131217.pushlogphid.2.mig.php'),
),
'20131217.pushlogphid.3.key.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20131217.pushlogphid.3.key.sql'),
),
);
}
}