Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14761096
D19652.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D19652.diff
View Options
diff --git a/resources/sql/autopatches/20180910.audit.01.searches.php b/resources/sql/autopatches/20180910.audit.01.searches.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180910.audit.01.searches.php
@@ -0,0 +1,54 @@
+<?php
+
+$table = new PhabricatorSavedQuery();
+$conn = $table->establishConnection('w');
+
+$status_map = array(
+ 0 => 'none',
+ 1 => 'needs-audit',
+ 2 => 'concern-raised',
+ 3 => 'partially-audited',
+ 4 => 'audited',
+ 5 => 'needs-verification',
+);
+
+foreach (new LiskMigrationIterator($table) as $query) {
+ if ($query->getEngineClassName() !== 'PhabricatorCommitSearchEngine') {
+ continue;
+ }
+
+ $parameters = $query->getParameters();
+ $status = idx($parameters, 'statuses');
+
+ if (!$status) {
+ // No saved "status" constraint.
+ continue;
+ }
+
+ if (!is_array($status)) {
+ // Saved constraint isn't a list.
+ continue;
+ }
+
+ // Migrate old integer values to new string values.
+ $old_status = $status;
+ foreach ($status as $key => $value) {
+ if (is_numeric($value)) {
+ $status[$key] = $status_map[$value];
+ }
+ }
+
+ if ($status === $old_status) {
+ // Nothing changed.
+ continue;
+ }
+
+ $parameters['statuses'] = $status;
+
+ queryfx(
+ $conn,
+ 'UPDATE %T SET parameters = %s WHERE id = %d',
+ $table->getTableName(),
+ phutil_json_encode($parameters),
+ $query->getID());
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 23, 11:15 PM (19 h, 3 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7038199
Default Alt Text
D19652.diff (1 KB)
Attached To
Mode
D19652: Migrate old commit saved queries to new audit status constants
Attached
Detach File
Event Timeline
Log In to Comment