1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00
phorge-phorge/resources/sql/patches/131.migraterevisionquery.php

32 lines
722 B
PHP
Raw Normal View History

<?php
$table = new DifferentialRevision();
$conn_w = $table->establishConnection('w');
echo "Migrating revisions";
do {
$revisions = id(new DifferentialRevision())
->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);
echo "\nDone.\n";