@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3$diff_table = new DifferentialDiff();
4$conn_w = $diff_table->establishConnection('w');
5
6$size = 1000;
7
8$row_iter = id(new LiskMigrationIterator($diff_table))->setPageSize($size);
9$chunk_iter = new PhutilChunkedIterator($row_iter, $size);
10
11foreach ($chunk_iter as $chunk) {
12 $sql = array();
13
14 foreach ($chunk as $diff) {
15 $id = $diff->getID();
16 echo pht('Migrating diff ID %d...', $id)."\n";
17
18 $phid = $diff->getPHID();
19 if (strlen($phid)) {
20 continue;
21 }
22
23 $type_diff = DifferentialDiffPHIDType::TYPECONST;
24 $new_phid = PhabricatorPHID::generateNewPHID($type_diff);
25
26 $sql[] = qsprintf(
27 $conn_w,
28 '(%d, %s)',
29 $id,
30 $new_phid);
31 }
32
33 if (!$sql) {
34 continue;
35 }
36
37 foreach (PhabricatorLiskDAO::chunkSQL($sql) as $sql_chunk) {
38 queryfx(
39 $conn_w,
40 'INSERT IGNORE INTO %T (id, phid) VALUES %LQ
41 ON DUPLICATE KEY UPDATE phid = VALUES(phid)',
42 $diff_table->getTableName(),
43 $sql_chunk);
44 }
45}
46
47echo pht('Done.')."\n";