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:
parent
3fd16a9ba5
commit
310373ebc4
2 changed files with 26 additions and 0 deletions
22
resources/sql/autopatches/20141113.auditdupes.php
Normal file
22
resources/sql/autopatches/20141113.auditdupes.php
Normal 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";
|
|
@ -27,6 +27,10 @@ final class PhabricatorRepositoryAuditRequest
|
|||
'auditorPHID' => array(
|
||||
'columns' => array('auditorPHID', 'auditStatus'),
|
||||
),
|
||||
'key_unique' => array(
|
||||
'columns' => array('commitPHID', 'auditorPHID'),
|
||||
'unique' => true,
|
||||
),
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue