1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-15 18:10:53 +01:00
phorge-phorge/resources/sql/autopatches/20140420.rel.2.objectmig.php
Joshua Spence 7cab903943 Migrate Differential revision edges to use modern EdgeType subclasses
Summary: Modernize Differential edges to subclass `PhabricatorEdgeType`. Largely based on D11045.

Test Plan: From previous experience, these changes are fairly trivial and safe. I poked around a little to make sure things looked reasonably okay.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, Krenair, epriestley

Differential Revision: https://secure.phabricator.com/D11074
2015-01-01 15:07:03 +11:00

45 lines
1.1 KiB
PHP

<?php
$pull_table = new ReleephRequest();
$table_name = $pull_table->getTableName();
$conn_w = $pull_table->establishConnection('w');
echo "Setting object PHIDs for requests...\n";
foreach (new LiskMigrationIterator($pull_table) as $pull) {
$id = $pull->getID();
echo "Migrating pull request {$id}...\n";
if ($pull->getRequestedObjectPHID()) {
// We already have a valid PHID, so skip this request.
continue;
}
$commit_phids = $pull->getCommitPHIDs();
if (count($commit_phids) != 1) {
// At the time this migration was written, all requests had exactly one
// commit. If a request has more than one, we don't have the information
// we need to process it.
continue;
}
$commit_phid = head($commit_phids);
$revision_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$commit_phid,
DiffusionCommitHasRevisionEdgeType::EDGECONST);
if ($revision_phids) {
$object_phid = head($revision_phids);
} else {
$object_phid = $commit_phid;
}
queryfx(
$conn_w,
'UPDATE %T SET requestedObjectPHID = %s WHERE id = %d',
$table_name,
$object_phid,
$id);
}
echo "Done.\n";