Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20180910.audit.03.status.php
<?php | <?php | ||||
$table = new PhabricatorRepositoryCommit(); | $table = new PhabricatorRepositoryCommit(); | ||||
$conn = $table->establishConnection('w'); | $conn = $table->establishConnection('w'); | ||||
$status_map = array( | $status_map = array( | ||||
0 => 'none', | 0 => 'none', | ||||
1 => 'needs-audit', | 1 => 'needs-audit', | ||||
2 => 'concern-raised', | 2 => 'concern-raised', | ||||
3 => 'partially-audited', | 3 => 'partially-audited', | ||||
4 => 'audited', | 4 => 'audited', | ||||
5 => 'needs-verification', | 5 => 'needs-verification', | ||||
); | ); | ||||
foreach (new LiskMigrationIterator($table) as $commit) { | foreach ($status_map as $old_status => $new_status) { | ||||
$status = $commit->getAuditStatus(); | |||||
if (!isset($status_map[$status])) { | |||||
continue; | |||||
} | |||||
queryfx( | queryfx( | ||||
$conn, | $conn, | ||||
'UPDATE %T SET auditStatus = %s WHERE id = %d', | 'UPDATE %R SET auditStatus = %s WHERE auditStatus = %s', | ||||
$table->getTableName(), | $table, | ||||
$status_map[$status], | $new_status, | ||||
$commit->getID()); | $old_status); | ||||
} | } |