1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-15 10:00:55 +01:00
phorge-phorge/resources/sql/autopatches/20140321.mstatus.2.mig.php
Chad Little d6a620be45 Update Maniphest for modular transactions
Summary: Ref T12671. This modernized Maniphest transactions to modular transactions.

Test Plan:
- Create Task
- Edit Task
- Raise Priority
- Change Status
- Merge as a duplicate
- Create Subtask
- Claim Task
- Assign Project
- Move on Workboard
- Set a cover image
- Assign story points
- Change story points
- Generate lots via lipsum
- Bulk edit tasks
- Leave comments
- Award Token

I'm sure I'm missing something.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: hazelyang, Korvin

Maniphest Tasks: T12671

Differential Revision: https://secure.phabricator.com/D17844
2017-05-15 10:29:06 -07:00

95 lines
2.3 KiB
PHP

<?php
$status_map = array(
0 => 'open',
1 => 'resolved',
2 => 'wontfix',
3 => 'invalid',
4 => 'duplicate',
5 => 'spite',
);
$conn_w = id(new ManiphestTask())->establishConnection('w');
echo pht('Migrating tasks to new status constants...')."\n";
foreach (new LiskMigrationIterator(new ManiphestTask()) as $task) {
$id = $task->getID();
echo pht('Migrating %s...', "T{$id}")."\n";
$status = $task->getStatus();
if (isset($status_map[$status])) {
queryfx(
$conn_w,
'UPDATE %T SET status = %s WHERE id = %d',
$task->getTableName(),
$status_map[$status],
$id);
}
}
echo pht('Done.')."\n";
echo pht('Migrating task transactions to new status constants...')."\n";
foreach (new LiskMigrationIterator(new ManiphestTransaction()) as $xaction) {
$id = $xaction->getID();
echo pht('Migrating %d...', $id)."\n";
$xn_type = ManiphestTaskStatusTransaction::TRANSACTIONTYPE;
if ($xaction->getTransactionType() == $xn_type) {
$old = $xaction->getOldValue();
if ($old !== null && isset($status_map[$old])) {
$old = $status_map[$old];
}
$new = $xaction->getNewValue();
if (isset($status_map[$new])) {
$new = $status_map[$new];
}
queryfx(
$conn_w,
'UPDATE %T SET oldValue = %s, newValue = %s WHERE id = %d',
$xaction->getTableName(),
json_encode($old),
json_encode($new),
$id);
}
}
echo pht('Done.')."\n";
$conn_w = id(new PhabricatorSavedQuery())->establishConnection('w');
echo pht('Migrating searches to new status constants...')."\n";
foreach (new LiskMigrationIterator(new PhabricatorSavedQuery()) as $query) {
$id = $query->getID();
echo pht('Migrating %d...', $id)."\n";
if ($query->getEngineClassName() !== 'ManiphestTaskSearchEngine') {
continue;
}
$params = $query->getParameters();
$statuses = idx($params, 'statuses', array());
if ($statuses) {
$changed = false;
foreach ($statuses as $key => $status) {
if (isset($status_map[$status])) {
$statuses[$key] = $status_map[$status];
$changed = true;
}
}
if ($changed) {
$params['statuses'] = $statuses;
queryfx(
$conn_w,
'UPDATE %T SET parameters = %s WHERE id = %d',
$query->getTableName(),
json_encode($params),
$id);
}
}
}
echo pht('Done.')."\n";