Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20180910.audit.01.searches.php
- This file was added.
<?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', | |||||
); | |||||
amckinley: I sanity-checked this against the code and it's correct, but isn't there an easy way to pull… | |||||
epriestleyAuthorUnsubmitted Done Inline ActionsI'm hard-coding the list in this migration (and two later migrations) so that I can remove the constants from PhabricatorAuditCommitStatusConstants without retaining any confusion/ambiguity going forward. epriestley: I'm hard-coding the list in this migration (and two later migrations) so that I can remove the… | |||||
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; | |||||
} | |||||
amckinleyUnsubmitted Not Done Inline ActionsSo "statuses": 1 as a constraint doesn't work? Or just malformed because diffusion.commit.search and audit.query are both expecting statuses to be list<string>, and this is just very defensive programming? amckinley: So `"statuses": 1` as a constraint doesn't work? Or just malformed because `diffusion.commit. | |||||
epriestleyAuthorUnsubmitted Done Inline ActionsYeah, this is mostly just defensive -- "statuses": 1 should be impossible. It also probably doesn't work. epriestley: Yeah, this is mostly just defensive -- `"statuses": 1` should be impossible. It //also//… | |||||
// 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()); | |||||
} |
I sanity-checked this against the code and it's correct, but isn't there an easy way to pull this array out of PhabricatorAuditCommitStatusConstants?