mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
96f9b0917e
Summary: Ref T13216. See PHI959. These two recent migrations can be expressed more efficiently: - When updating commit audit statuses, the field isn't JSON encoded or anything so we can just issue several bulk UPDATEs. - When inserting mail keys, we can batch them in groups of 100. Test Plan: Used `bin/storage upgrade -f --apply phabricator:...` to reapply patches. Saw equivalent behavior and faster runtimes. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13216 Differential Revision: https://secure.phabricator.com/D19802
34 lines
899 B
PHP
34 lines
899 B
PHP
<?php
|
|
|
|
$commit_table = new PhabricatorRepositoryCommit();
|
|
$commit_conn = $commit_table->establishConnection('w');
|
|
$commit_name = $commit_table->getTableName();
|
|
|
|
$properties_table = new PhabricatorMetaMTAMailProperties();
|
|
$conn = $properties_table->establishConnection('w');
|
|
|
|
$iterator = new LiskRawMigrationIterator($commit_conn, $commit_name);
|
|
$chunks = new PhutilChunkedIterator($iterator, 100);
|
|
foreach ($chunks as $chunk) {
|
|
$sql = array();
|
|
foreach ($chunk as $commit) {
|
|
$sql[] = qsprintf(
|
|
$conn,
|
|
'(%s, %s, %d, %d)',
|
|
$commit['phid'],
|
|
phutil_json_encode(
|
|
array(
|
|
'mailKey' => $commit['mailKey'],
|
|
)),
|
|
PhabricatorTime::getNow(),
|
|
PhabricatorTime::getNow());
|
|
}
|
|
|
|
queryfx(
|
|
$conn,
|
|
'INSERT IGNORE INTO %R
|
|
(objectPHID, mailProperties, dateCreated, dateModified)
|
|
VALUES %LQ',
|
|
$properties_table,
|
|
$sql);
|
|
}
|