mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
e10fdbe77e
Summary: Patches often read from slaves (possibly stale data) and use that information to write on master. It causes problems when applying more patches quickly after each other because data created in previous patch may not be replicated yet. Test Plan: $ bin/storage upgrade Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4483
35 lines
802 B
PHP
35 lines
802 B
PHP
<?php
|
|
|
|
$table = new DifferentialRevision();
|
|
$table->openTransaction();
|
|
$table->beginReadLocking();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
echo "Migrating revisions";
|
|
do {
|
|
$revisions = $table->loadAllWhere('branchName IS NULL LIMIT 1000');
|
|
|
|
foreach ($revisions as $revision) {
|
|
echo ".";
|
|
|
|
$diff = $revision->loadActiveDiff();
|
|
if (!$diff) {
|
|
continue;
|
|
}
|
|
|
|
$branch_name = $diff->getBranch();
|
|
$arc_project_phid = $diff->getArcanistProjectPHID();
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'UPDATE %T SET branchName = %s, arcanistProjectPHID = %s WHERE id = %d',
|
|
$table->getTableName(),
|
|
$branch_name,
|
|
$arc_project_phid,
|
|
$revision->getID());
|
|
}
|
|
} while (count($revisions) == 1000);
|
|
|
|
$table->endReadLocking();
|
|
$table->saveTransaction();
|
|
echo "\nDone.\n";
|