@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
3echo pht('Populating files with mail keys...')."\n";
4
5$table = new PhabricatorFile();
6$table_name = $table->getTableName();
7
8$conn_w = $table->establishConnection('w');
9$conn_w->openTransaction();
10
11$sql = array();
12foreach (new LiskRawMigrationIterator($conn_w, 'file') as $row) {
13 // NOTE: MySQL requires that the INSERT specify all columns which don't
14 // have default values when configured in strict mode. This query will
15 // never actually insert rows, but we need to hand it values anyway.
16
17 $sql[] = qsprintf(
18 $conn_w,
19 '(%d, %s, 0, 0, 0, 0, 0, 0, 0, 0)',
20 $row['id'],
21 Filesystem::readRandomCharacters(20));
22}
23
24if ($sql) {
25 foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
26 queryfx(
27 $conn_w,
28 'INSERT INTO %T
29 (id, mailKey, phid, byteSize, storageEngine, storageFormat,
30 storageHandle, dateCreated, dateModified, metadata) VALUES %LQ '.
31 'ON DUPLICATE KEY UPDATE mailKey = VALUES(mailKey)',
32 $table_name,
33 $chunk);
34 }
35}
36
37$table->saveTransaction();
38echo pht('Done.')."\n";