2013-09-05 22:11:02 +02:00
|
|
|
<?php
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Populating Phabricator files with mail keys xactions...')."\n";
|
2013-09-05 22:11:02 +02:00
|
|
|
|
|
|
|
$table = new PhabricatorFile();
|
|
|
|
$table_name = $table->getTableName();
|
|
|
|
|
|
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
$conn_w->openTransaction();
|
|
|
|
|
|
|
|
$sql = array();
|
|
|
|
foreach (new LiskRawMigrationIterator($conn_w, 'file') as $row) {
|
2013-09-06 00:58:28 +02:00
|
|
|
// NOTE: MySQL requires that the INSERT specify all columns which don't
|
|
|
|
// have default values when configured in strict mode. This query will
|
|
|
|
// never actually insert rows, but we need to hand it values anyway.
|
|
|
|
|
2013-09-05 22:11:02 +02:00
|
|
|
$sql[] = qsprintf(
|
|
|
|
$conn_w,
|
2013-09-06 00:58:28 +02:00
|
|
|
'(%d, %s, 0, 0, 0, 0, 0, 0, 0, 0)',
|
2013-09-05 22:11:02 +02:00
|
|
|
$row['id'],
|
|
|
|
Filesystem::readRandomCharacters(20));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($sql) {
|
2018-11-07 01:57:55 +01:00
|
|
|
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
|
2013-09-05 22:11:02 +02:00
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
2013-09-06 00:58:28 +02:00
|
|
|
'INSERT INTO %T
|
|
|
|
(id, mailKey, phid, byteSize, storageEngine, storageFormat,
|
2018-11-07 01:57:55 +01:00
|
|
|
storageHandle, dateCreated, dateModified, metadata) VALUES %LQ '.
|
2013-09-05 22:11:02 +02:00
|
|
|
'ON DUPLICATE KEY UPDATE mailKey = VALUES(mailKey)',
|
|
|
|
$table_name,
|
|
|
|
$chunk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->saveTransaction();
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|