mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Fix patch 131 for db with lots of revisions
Summary: The old version of this loads all differential revisions at once, but that much can't all be loaded into memory when there are close to 500,000 revisions. This diff splits up loading the revisions. Test Plan: Ran this to run the migration in our install Reviewers: jungejason, epriestley Reviewed By: epriestley CC: aran Differential Revision: https://secure.phabricator.com/D2243
This commit is contained in:
parent
283fee7c0a
commit
1ea8bd3ab7
1 changed files with 22 additions and 19 deletions
|
@ -19,26 +19,29 @@
|
||||||
$table = new DifferentialRevision();
|
$table = new DifferentialRevision();
|
||||||
$conn_w = $table->establishConnection('w');
|
$conn_w = $table->establishConnection('w');
|
||||||
|
|
||||||
$revisions = id(new DifferentialRevision())->loadAll();
|
echo "Migrating revisions";
|
||||||
|
do {
|
||||||
|
$revisions = id(new DifferentialRevision())
|
||||||
|
->loadAllWhere('branchName IS NULL LIMIT 1000');
|
||||||
|
|
||||||
echo "Migrating ".count($revisions)." revisions";
|
foreach ($revisions as $revision) {
|
||||||
foreach ($revisions as $revision) {
|
echo ".";
|
||||||
echo ".";
|
|
||||||
|
|
||||||
$diff = $revision->loadActiveDiff();
|
$diff = $revision->loadActiveDiff();
|
||||||
if (!$diff) {
|
if (!$diff) {
|
||||||
continue;
|
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);
|
||||||
$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());
|
|
||||||
}
|
|
||||||
echo "\nDone.\n";
|
echo "\nDone.\n";
|
||||||
|
|
Loading…
Reference in a new issue