@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$table = new AlmanacProperty();
4$conn_w = $table->establishConnection('w');
5
6// We're going to JSON-encode the value in each row: previously rows stored
7// plain strings, but now they store JSON, so we need to update them.
8
9foreach (new LiskMigrationIterator($table) as $property) {
10 $key = $property->getFieldName();
11
12 $current_row = queryfx_one(
13 $conn_w,
14 'SELECT fieldValue FROM %T WHERE id = %d',
15 $table->getTableName(),
16 $property->getID());
17
18 if (!$current_row) {
19 continue;
20 }
21
22 queryfx(
23 $conn_w,
24 'UPDATE %T SET fieldValue = %s WHERE id = %d',
25 $table->getTableName(),
26 phutil_json_encode($current_row['fieldValue']),
27 $property->getID());
28}