mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +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:
parent
2216a5e6ef
commit
f28d3089d7
7 changed files with 88 additions and 0 deletions
2
resources/sql/patches/20131217.pushlogphid.1.col.sql
Normal file
2
resources/sql/patches/20131217.pushlogphid.1.col.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_repository.repository_pushlog
|
||||||
|
ADD phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id;
|
20
resources/sql/patches/20131217.pushlogphid.2.mig.php
Normal file
20
resources/sql/patches/20131217.pushlogphid.2.mig.php
Normal 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";
|
2
resources/sql/patches/20131217.pushlogphid.3.key.sql
Normal file
2
resources/sql/patches/20131217.pushlogphid.3.key.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_repository.repository_pushlog
|
||||||
|
ADD UNIQUE KEY `key_phid` (phid);
|
|
@ -1798,6 +1798,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRepositoryPHIDTypeArcanistProject' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeArcanistProject.php',
|
'PhabricatorRepositoryPHIDTypeArcanistProject' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeArcanistProject.php',
|
||||||
'PhabricatorRepositoryPHIDTypeCommit' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeCommit.php',
|
'PhabricatorRepositoryPHIDTypeCommit' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeCommit.php',
|
||||||
'PhabricatorRepositoryPHIDTypeMirror' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeMirror.php',
|
'PhabricatorRepositoryPHIDTypeMirror' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeMirror.php',
|
||||||
|
'PhabricatorRepositoryPHIDTypePushLog' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypePushLog.php',
|
||||||
'PhabricatorRepositoryPHIDTypeRepository' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php',
|
'PhabricatorRepositoryPHIDTypeRepository' => 'applications/repository/phid/PhabricatorRepositoryPHIDTypeRepository.php',
|
||||||
'PhabricatorRepositoryPullEngine' => 'applications/repository/engine/PhabricatorRepositoryPullEngine.php',
|
'PhabricatorRepositoryPullEngine' => 'applications/repository/engine/PhabricatorRepositoryPullEngine.php',
|
||||||
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php',
|
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php',
|
||||||
|
@ -4363,6 +4364,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRepositoryPHIDTypeArcanistProject' => 'PhabricatorPHIDType',
|
'PhabricatorRepositoryPHIDTypeArcanistProject' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorRepositoryPHIDTypeCommit' => 'PhabricatorPHIDType',
|
'PhabricatorRepositoryPHIDTypeCommit' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorRepositoryPHIDTypeMirror' => 'PhabricatorPHIDType',
|
'PhabricatorRepositoryPHIDTypeMirror' => 'PhabricatorPHIDType',
|
||||||
|
'PhabricatorRepositoryPHIDTypePushLog' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorRepositoryPHIDTypeRepository' => 'PhabricatorPHIDType',
|
'PhabricatorRepositoryPHIDTypeRepository' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorRepositoryPullEngine' => 'PhabricatorRepositoryEngine',
|
'PhabricatorRepositoryPullEngine' => 'PhabricatorRepositoryEngine',
|
||||||
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon',
|
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon',
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -57,10 +57,16 @@ final class PhabricatorRepositoryPushLog
|
||||||
|
|
||||||
public function getConfiguration() {
|
public function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
|
self::CONFIG_AUX_PHID => true,
|
||||||
self::CONFIG_TIMESTAMPS => false,
|
self::CONFIG_TIMESTAMPS => false,
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generatePHID() {
|
||||||
|
return PhabricatorPHID::generateNewPHID(
|
||||||
|
PhabricatorRepositoryPHIDTypePushLog::TYPECONST);
|
||||||
|
}
|
||||||
|
|
||||||
public function attachRepository(PhabricatorRepository $repository) {
|
public function attachRepository(PhabricatorRepository $repository) {
|
||||||
$this->repository = $repository;
|
$this->repository = $repository;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -1832,6 +1832,18 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
||||||
'type' => 'sql',
|
'type' => 'sql',
|
||||||
'name' => $this->getPatchPath('20131211.phragmentedges.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'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue