2013-10-05 22:48:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$table = new DifferentialRevision();
|
|
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
|
|
|
|
// NOTE: We migrate by revision because the relationship table doesn't have
|
|
|
|
// an "id" column.
|
|
|
|
|
|
|
|
foreach (new LiskMigrationIterator($table) as $revision) {
|
|
|
|
$revision_id = $revision->getID();
|
|
|
|
$revision_phid = $revision->getPHID();
|
|
|
|
|
|
|
|
echo "Migrating reviewers for D{$revision_id}...\n";
|
|
|
|
|
|
|
|
$reviewer_phids = queryfx_all(
|
|
|
|
$conn_w,
|
|
|
|
'SELECT objectPHID FROM %T WHERE revisionID = %d
|
|
|
|
AND relation = %s ORDER BY sequence',
|
|
|
|
'differential_relationship',
|
|
|
|
$revision_id,
|
|
|
|
'revw');
|
|
|
|
$reviewer_phids = ipull($reviewer_phids, 'objectPHID');
|
|
|
|
|
|
|
|
if (!$reviewer_phids) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-07-18 00:41:42 +02:00
|
|
|
$editor = new PhabricatorEdgeEditor();
|
2013-10-05 22:48:45 +02:00
|
|
|
foreach ($reviewer_phids as $dst) {
|
2014-04-23 23:22:02 +02:00
|
|
|
if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
|
|
|
|
// At least one old install ran into some issues here. Skip the row if we
|
|
|
|
// can't figure out what the destination PHID is. See here:
|
2014-05-29 17:33:25 +02:00
|
|
|
// https://github.com/phacility/phabricator/pull/507
|
2014-04-23 23:22:02 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-10-05 22:48:45 +02:00
|
|
|
$editor->addEdge(
|
|
|
|
$revision_phid,
|
2015-01-01 04:43:26 +01:00
|
|
|
DifferentialRevisionHasReviewerEdgeType::EDGECONST,
|
2013-10-05 22:48:45 +02:00
|
|
|
$dst,
|
|
|
|
array(
|
|
|
|
'data' => array(
|
|
|
|
'status' => DifferentialReviewerStatus::STATUS_ADDED,
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
$editor->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Done.\n";
|