mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-28 07:28:20 +01:00
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
This commit is contained in:
parent
4aba4ddb2c
commit
d9db1d61e0
3 changed files with 62 additions and 1 deletions
38
resources/sql/patches/20131118.ownerorder.php
Normal file
38
resources/sql/patches/20131118.ownerorder.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?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";
|
|
@ -117,7 +117,26 @@ final class ManiphestTransactionEditor
|
||||||
case ManiphestTransaction::TYPE_DESCRIPTION:
|
case ManiphestTransaction::TYPE_DESCRIPTION:
|
||||||
return $object->setDescription($xaction->getNewValue());
|
return $object->setDescription($xaction->getNewValue());
|
||||||
case ManiphestTransaction::TYPE_OWNER:
|
case ManiphestTransaction::TYPE_OWNER:
|
||||||
return $object->setOwnerPHID($xaction->getNewValue());
|
$phid = $xaction->getNewValue();
|
||||||
|
|
||||||
|
// Update the "ownerOrdering" column to contain the full name of the
|
||||||
|
// owner, if the task is assigned.
|
||||||
|
|
||||||
|
$handle = null;
|
||||||
|
if ($phid) {
|
||||||
|
$handle = id(new PhabricatorHandleQuery())
|
||||||
|
->setViewer($this->getActor())
|
||||||
|
->withPHIDs(array($phid))
|
||||||
|
->executeOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($handle) {
|
||||||
|
$object->setOwnerOrdering($handle->getName());
|
||||||
|
} else {
|
||||||
|
$object->setOwnerOrdering(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object->setOwnerPHID($phid);
|
||||||
case ManiphestTransaction::TYPE_CCS:
|
case ManiphestTransaction::TYPE_CCS:
|
||||||
return $object->setCCPHIDs($xaction->getNewValue());
|
return $object->setCCPHIDs($xaction->getNewValue());
|
||||||
case ManiphestTransaction::TYPE_PROJECTS:
|
case ManiphestTransaction::TYPE_PROJECTS:
|
||||||
|
|
|
@ -1756,6 +1756,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
||||||
'type' => 'php',
|
'type' => 'php',
|
||||||
'name' => $this->getPatchPath('20131112.userverified.2.mig.php'),
|
'name' => $this->getPatchPath('20131112.userverified.2.mig.php'),
|
||||||
),
|
),
|
||||||
|
'20131118.ownerorder.php' => array(
|
||||||
|
'type' => 'php',
|
||||||
|
'name' => $this->getPatchPath('20131118.ownerorder.php'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue