1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00
phorge-phorge/resources/sql/patches/20130820.file-mailkey-populate.php

33 lines
709 B
PHP
Raw Normal View History

<?php
echo "Populating Phabricator files with mail keys xactions...\n";
$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) {
$sql[] = qsprintf(
$conn_w,
'(%d, %s)',
$row['id'],
Filesystem::readRandomCharacters(20));
}
if ($sql) {
foreach (PhabricatorLiskDAO::chunkSQL($sql, ', ') as $chunk) {
queryfx(
$conn_w,
'INSERT INTO %T (id, mailKey) VALUES %Q '.
'ON DUPLICATE KEY UPDATE mailKey = VALUES(mailKey)',
$table_name,
$chunk);
}
}
$table->saveTransaction();
echo "Done.\n";