mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
65ddefad8b
Summary: Ref T1279. @champo did a lot of this work already; we've been doing double writes for a long time. Add "double reads" (reading the edge table as both the "relationship" table and as the "reviewer status" table), and migrate all the data. I'm not bothering to try to recover old reviewer status (e.g., we could infer from transactions who accepted old revisions) because it wold be very complicated and doesn't seem too valuable. Test Plan: - Without doing the migration, used Differential. Verified that reads and writes worked. Most of the data was there anyway since we've been double-writing. - Performed the migration. Verified that everything was still unchanged. - Dropped the edge table, verified all reviweer data vanished. - Migrated again, verified the reviewer stuff was restored. - Did various cc/reviewer/subscriber queries, got consistent results. Reviewers: btrahan Reviewed By: btrahan CC: champo, aran Maniphest Tasks: T1279 Differential Revision: https://secure.phabricator.com/D7227
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?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;
|
|
}
|
|
|
|
$editor = id(new PhabricatorEdgeEditor())
|
|
->setActor(PhabricatorUser::getOmnipotentUser());
|
|
|
|
foreach ($reviewer_phids as $dst) {
|
|
$editor->addEdge(
|
|
$revision_phid,
|
|
PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER,
|
|
$dst,
|
|
array(
|
|
'data' => array(
|
|
'status' => DifferentialReviewerStatus::STATUS_ADDED,
|
|
),
|
|
));
|
|
}
|
|
|
|
$editor->save();
|
|
}
|
|
|
|
echo "Done.\n";
|