1
0
Fork 0
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:
Nick Harper 2012-04-16 12:35:48 -07:00
parent 283fee7c0a
commit 1ea8bd3ab7

View file

@ -19,26 +19,29 @@
$table = new DifferentialRevision();
$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) {
echo ".";
foreach ($revisions as $revision) {
echo ".";
$diff = $revision->loadActiveDiff();
if (!$diff) {
continue;
$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());
}
$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);
echo "\nDone.\n";