Page MenuHomePhabricator

D10849.diff
No OneTemporary

D10849.diff

diff --git a/resources/sql/autopatches/20141113.auditdupes.php b/resources/sql/autopatches/20141113.auditdupes.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20141113.auditdupes.php
@@ -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";
diff --git a/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php b/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php
--- a/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php
@@ -27,6 +27,10 @@
'auditorPHID' => array(
'columns' => array('auditorPHID', 'auditStatus'),
),
+ 'key_unique' => array(
+ 'columns' => array('commitPHID', 'auditorPHID'),
+ 'unique' => true,
+ ),
),
) + parent::getConfiguration();
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 29, 2:12 AM (8 h, 38 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6941494
Default Alt Text
D10849.diff (1 KB)

Event Timeline