mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
a5f55d506f
Summary: Ref T4677. Currently, we record individual actions in a push as PhabricatorRepositoryPushLogs, but tie them together only loosely with a `transactionKey`. Provide a real PushEvent object, and move some of the denormalized fields to it. This primarily just gives us more robust infrastructure for building, e.g., email about pushes, for T4677, since we can act on real PHIDs rather than passing awkward identifiers around. Test Plan: - Performed migration. - Looked at database for consistency. - Browsed/queried push logs. - Pushed a bunch of stuff. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4677 Differential Revision: https://secure.phabricator.com/D8615
43 lines
1 KiB
PHP
43 lines
1 KiB
PHP
<?php
|
|
|
|
$conn_w = id(new PhabricatorRepository())->establishConnection('w');
|
|
|
|
echo "Adding transaction log event groups...\n";
|
|
|
|
$logs = queryfx_all(
|
|
$conn_w,
|
|
'SELECT * FROM %T GROUP BY transactionKey ORDER BY id ASC',
|
|
'repository_pushlog');
|
|
foreach ($logs as $log) {
|
|
$id = $log['id'];
|
|
echo "Migrating log {$id}...\n";
|
|
if ($log['pushEventPHID']) {
|
|
continue;
|
|
}
|
|
|
|
$event_phid = id(new PhabricatorRepositoryPushEvent())->generatePHID();
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'INSERT INTO %T (phid, repositoryPHID, epoch, pusherPHID, remoteAddress,
|
|
remoteProtocol, rejectCode, rejectDetails)
|
|
VALUES (%s, %s, %d, %s, %d, %s, %d, %s)',
|
|
'repository_pushevent',
|
|
$event_phid,
|
|
$log['repositoryPHID'],
|
|
$log['epoch'],
|
|
$log['pusherPHID'],
|
|
$log['remoteAddress'],
|
|
$log['remoteProtocol'],
|
|
$log['rejectCode'],
|
|
$log['rejectDetails']);
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'UPDATE %T SET pushEventPHID = %s WHERE transactionKey = %s',
|
|
'repository_pushlog',
|
|
$event_phid,
|
|
$log['transactionKey']);
|
|
}
|
|
|
|
echo "Done.\n";
|