Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/migrate-maniphest-dependencies.php
| <?php | <?php | ||||
| echo "Migrating task dependencies to edges...\n"; | echo pht('Migrating task dependencies to edges...')."\n"; | ||||
| $table = new ManiphestTask(); | $table = new ManiphestTask(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| foreach (new LiskMigrationIterator($table) as $task) { | foreach (new LiskMigrationIterator($table) as $task) { | ||||
| $id = $task->getID(); | $id = $task->getID(); | ||||
| echo "Task {$id}: "; | echo pht('Task %d: ', $id); | ||||
| $deps = $task->getAttachedPHIDs(ManiphestTaskPHIDType::TYPECONST); | $deps = $task->getAttachedPHIDs(ManiphestTaskPHIDType::TYPECONST); | ||||
| if (!$deps) { | if (!$deps) { | ||||
| echo "-\n"; | echo "-\n"; | ||||
| continue; | continue; | ||||
| } | } | ||||
| $editor = new PhabricatorEdgeEditor(); | $editor = new PhabricatorEdgeEditor(); | ||||
| foreach ($deps as $dep) { | foreach ($deps as $dep) { | ||||
| $editor->addEdge( | $editor->addEdge( | ||||
| $task->getPHID(), | $task->getPHID(), | ||||
| ManiphestTaskDependsOnTaskEdgeType::EDGECONST, | ManiphestTaskDependsOnTaskEdgeType::EDGECONST, | ||||
| $dep); | $dep); | ||||
| } | } | ||||
| $editor->save(); | $editor->save(); | ||||
| echo "OKAY\n"; | echo pht('OKAY')."\n"; | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||