1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-02 11:42:42 +01:00
phorge-phorge/resources/sql/patches/20131118.ownerorder.php
epriestley d9db1d61e0 Restore population of ownerOrdering to ManiphestTasks
Summary:
Ref T4110. This denormalized field used to power "Group By: Assigned" got dropped in the T2217 migration at some point.

Restore its population, and fix all the data in the database.

Test Plan: Ran migration, verified database came out reasonable-looking. Reassigned a task, verified database. Ran a "Group By: assigned" query.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4110

Differential Revision: https://secure.phabricator.com/D7602
2013-11-19 14:10:54 -08:00

38 lines
837 B
PHP

<?php
$table = new ManiphestTask();
$conn_w = $table->establishConnection('w');
foreach (new LiskMigrationIterator($table) as $task) {
$id = $task->getID();
echo "Checking task T{$id}...\n";
$owner_phid = $task->getOwnerPHID();
if (!$owner_phid && !$task->getOwnerOrdering()) {
// No owner and no ordering; we're all set.
continue;
}
$owner_handle = id(new PhabricatorHandleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs(array($owner_phid))
->executeOne();
if ($owner_handle) {
$value = $owner_handle->getName();
} else {
$value = null;
}
if ($value !== $task->getOwnerOrdering()) {
queryfx(
$conn_w,
'UPDATE %T SET ownerOrdering = %ns WHERE id = %d',
$table->getTableName(),
$value,
$task->getID());
}
}
echo "Done.\n";