@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// Old images used a "mockID" instead of a "mockPHID" to reference mocks.
4// Set the "mockPHID" column to the value that corresponds to the "mockID".
5
6$image = new PholioImage();
7$mock = new PholioMock();
8
9$conn = $image->establishConnection('w');
10$iterator = new LiskRawMigrationIterator($conn, $image->getTableName());
11
12foreach ($iterator as $image_row) {
13 if ($image_row['mockPHID']) {
14 continue;
15 }
16
17 $mock_id = $image_row['mockID'];
18
19 $mock_row = queryfx_one(
20 $conn,
21 'SELECT phid FROM %R WHERE id = %d',
22 $mock,
23 $mock_id);
24
25 if (!$mock_row) {
26 continue;
27 }
28
29 queryfx(
30 $conn,
31 'UPDATE %R SET mockPHID = %s WHERE id = %d',
32 $image,
33 $mock_row['phid'],
34 $image_row['id']);
35}