mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
09703938fb
Summary: Depends on D19651. Ref T13197. The application now accepts either numeric or string values. However, for consistency and to reduce surprise in the future, migrate existing saved queries to use string values. Test Plan: Saved some queries on `master` with numeric constants, ran the migration, saw string constants in the database and equivalent behavior in the UI. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13197 Differential Revision: https://secure.phabricator.com/D19652
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?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());
|
|
}
|