Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/20131106.diffphid.2.mig.php
| <?php | <?php | ||||
| $diff_table = new DifferentialDiff(); | $diff_table = new DifferentialDiff(); | ||||
| $conn_w = $diff_table->establishConnection('w'); | $conn_w = $diff_table->establishConnection('w'); | ||||
| $size = 1000; | $size = 1000; | ||||
| $row_iter = id(new LiskMigrationIterator($diff_table))->setPageSize($size); | $row_iter = id(new LiskMigrationIterator($diff_table))->setPageSize($size); | ||||
| $chunk_iter = new PhutilChunkedIterator($row_iter, $size); | $chunk_iter = new PhutilChunkedIterator($row_iter, $size); | ||||
| foreach ($chunk_iter as $chunk) { | foreach ($chunk_iter as $chunk) { | ||||
| $sql = array(); | $sql = array(); | ||||
| foreach ($chunk as $diff) { | foreach ($chunk as $diff) { | ||||
| $id = $diff->getID(); | $id = $diff->getID(); | ||||
| echo "Migrating diff ID {$id}...\n"; | echo pht('Migrating diff ID %d...', $id)."\n"; | ||||
| $phid = $diff->getPHID(); | $phid = $diff->getPHID(); | ||||
| if (strlen($phid)) { | if (strlen($phid)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $type_diff = DifferentialDiffPHIDType::TYPECONST; | $type_diff = DifferentialDiffPHIDType::TYPECONST; | ||||
| $new_phid = PhabricatorPHID::generateNewPHID($type_diff); | $new_phid = PhabricatorPHID::generateNewPHID($type_diff); | ||||
| Show All 14 Lines | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'INSERT IGNORE INTO %T (id, phid) VALUES %Q | 'INSERT IGNORE INTO %T (id, phid) VALUES %Q | ||||
| ON DUPLICATE KEY UPDATE phid = VALUES(phid)', | ON DUPLICATE KEY UPDATE phid = VALUES(phid)', | ||||
| $diff_table->getTableName(), | $diff_table->getTableName(), | ||||
| $sql_chunk); | $sql_chunk); | ||||
| } | } | ||||
| } | } | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||