Page MenuHomePhabricator

D19182.id45949.diff
No OneTemporary

D19182.id45949.diff

diff --git a/resources/sql/autopatches/20180306.opath.03.purge.php b/resources/sql/autopatches/20180306.opath.03.purge.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180306.opath.03.purge.php
@@ -0,0 +1,22 @@
+<?php
+
+$table = new PhabricatorOwnersPath();
+$conn = $table->establishConnection('w');
+
+$seen = array();
+foreach (new LiskMigrationIterator($table) as $path) {
+ $package_id = $path->getPackageID();
+ $repository_phid = $path->getRepositoryPHID();
+ $path_index = $path->getPathIndex();
+
+ if (!isset($seen[$package_id][$repository_phid][$path_index])) {
+ $seen[$package_id][$repository_phid][$path_index] = true;
+ continue;
+ }
+
+ queryfx(
+ $conn,
+ 'DELETE FROM %T WHERE id = %d',
+ $table->getTableName(),
+ $path->getID());
+}
diff --git a/resources/sql/autopatches/20180306.opath.04.unique.sql b/resources/sql/autopatches/20180306.opath.04.unique.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180306.opath.04.unique.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_owners.owners_path
+ ADD UNIQUE KEY `key_path` (packageID, repositoryPHID, pathIndex);
diff --git a/src/applications/owners/storage/PhabricatorOwnersPath.php b/src/applications/owners/storage/PhabricatorOwnersPath.php
--- a/src/applications/owners/storage/PhabricatorOwnersPath.php
+++ b/src/applications/owners/storage/PhabricatorOwnersPath.php
@@ -20,8 +20,9 @@
'excluded' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
- 'packageID' => array(
- 'columns' => array('packageID'),
+ 'key_path' => array(
+ 'columns' => array('packageID', 'repositoryPHID', 'pathIndex'),
+ 'unique' => true,
),
),
) + parent::getConfiguration();

File Metadata

Mime Type
text/plain
Expires
Sat, May 11, 12:01 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6285550
Default Alt Text
D19182.id45949.diff (1 KB)

Event Timeline