Page MenuHomePhabricator

D19379.id46356.diff
No OneTemporary

D19379.id46356.diff

diff --git a/resources/sql/autopatches/20170417.alamanc.network.unique.sql b/resources/sql/autopatches/20170417.alamanc.network.unique.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170417.alamanc.network.unique.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_almanac.almanac_network
+ ADD UNIQUE KEY `key_name` (name);
diff --git a/resources/sql/autopatches/20180417.almanac.unique.sql b/resources/sql/autopatches/20180417.almanac.unique.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180417.almanac.unique.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_almanac.almanac_interface
+ ADD UNIQUE KEY `key_unique` (devicePHID, networkPHID, address, port);
diff --git a/src/applications/almanac/query/AlmanacNetworkQuery.php b/src/applications/almanac/query/AlmanacNetworkQuery.php
--- a/src/applications/almanac/query/AlmanacNetworkQuery.php
+++ b/src/applications/almanac/query/AlmanacNetworkQuery.php
@@ -5,6 +5,7 @@
private $ids;
private $phids;
+ private $names;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -20,6 +21,11 @@
return new AlmanacNetwork();
}
+ public function withNames(array $names) {
+ $this->names = $names;
+ return $this;
+ }
+
public function withNameNgrams($ngrams) {
return $this->withNgramsConstraint(
new AlmanacNetworkNameNgrams(),
@@ -47,6 +53,13 @@
$this->phids);
}
+ if ($this->names !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'network.name IN (%Ls)',
+ $this->names);
+ }
+
return $where;
}
diff --git a/src/applications/almanac/storage/AlmanacInterface.php b/src/applications/almanac/storage/AlmanacInterface.php
--- a/src/applications/almanac/storage/AlmanacInterface.php
+++ b/src/applications/almanac/storage/AlmanacInterface.php
@@ -35,6 +35,10 @@
'key_device' => array(
'columns' => array('devicePHID'),
),
+ 'key_unique' => array(
+ 'columns' => array('devicePHID', 'networkPHID', 'address', 'port'),
+ 'unique' => true,
+ ),
),
) + parent::getConfiguration();
}
diff --git a/src/applications/almanac/storage/AlmanacNetwork.php b/src/applications/almanac/storage/AlmanacNetwork.php
--- a/src/applications/almanac/storage/AlmanacNetwork.php
+++ b/src/applications/almanac/storage/AlmanacNetwork.php
@@ -26,6 +26,13 @@
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text128',
'mailKey' => 'bytes20',
+
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_name' => array(
+ 'columns' => array('name'),
+ 'unique' => true,
+ ),
),
) + parent::getConfiguration();
}

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 20, 3:34 AM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6734962
Default Alt Text
D19379.id46356.diff (2 KB)

Event Timeline