1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Audit - delete duplicate audit requests and add unique key

Summary: Fixes T1768. This is mostly a data cleanliness issue as duplicate rows don't really do anything, but let's clear it up now.

Test Plan: made some duplicate rows by adding the same auditor multiple times. ran ./bin/storage upgrade and it worked perfectly!

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T1768

Differential Revision: https://secure.phabricator.com/D10849
This commit is contained in:
Bob Trahan 2014-11-13 16:11:57 -08:00
parent 3fd16a9ba5
commit 310373ebc4
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,22 @@
<?php
$table = new PhabricatorRepositoryAuditRequest();
$conn_w = $table->establishConnection('w');
echo "Removing duplicate Audit requests...\n";
$seen_audit_map = array();
foreach (new LiskMigrationIterator($table) as $request) {
$commit_phid = $request->getCommitPHID();
$auditor_phid = $request->getAuditorPHID();
if (isset($seen_audit_map[$commit_phid][$auditor_phid])) {
$request->delete();
}
if (!isset($seen_audit_map[$commit_phid])) {
$seen_audit_map[$commit_phid] = array();
}
$seen_audit_map[$commit_phid][$auditor_phid] = 1;
}
echo "Done.\n";

View file

@ -27,6 +27,10 @@ final class PhabricatorRepositoryAuditRequest
'auditorPHID' => array(
'columns' => array('auditorPHID', 'auditStatus'),
),
'key_unique' => array(
'columns' => array('commitPHID', 'auditorPHID'),
'unique' => true,
),
),
) + parent::getConfiguration();
}