Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20141222.maniphestprojtxn.php
| <?php | <?php | ||||
| $table = new ManiphestTransaction(); | $table = new ManiphestTransaction(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| echo "Converting Maniphest project transactions to modern EDGE ". | echo pht( | ||||
| "transactions...\n"; | "Converting Maniphest project transactions to modern edge transactions...\n"); | ||||
| $metadata = array( | $metadata = array( | ||||
| 'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | 'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | ||||
| ); | ); | ||||
| foreach (new LiskMigrationIterator($table) as $txn) { | foreach (new LiskMigrationIterator($table) as $txn) { | ||||
| // ManiphestTransaction::TYPE_PROJECTS | // ManiphestTransaction::TYPE_PROJECTS | ||||
| if ($txn->getTransactionType() == 'projects') { | if ($txn->getTransactionType() == 'projects') { | ||||
| $old_value = mig20141222_build_edge_data( | $old_value = mig20141222_build_edge_data( | ||||
| $txn->getOldValue(), | $txn->getOldValue(), | ||||
| Show All 10 Lines | queryfx( | ||||
| PhabricatorTransactions::TYPE_EDGE, | PhabricatorTransactions::TYPE_EDGE, | ||||
| json_encode($old_value), | json_encode($old_value), | ||||
| json_encode($new_value), | json_encode($new_value), | ||||
| json_encode($metadata), | json_encode($metadata), | ||||
| $txn->getID()); | $txn->getID()); | ||||
| } | } | ||||
| } | } | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||
| function mig20141222_build_edge_data(array $project_phids, $task_phid) { | function mig20141222_build_edge_data(array $project_phids, $task_phid) { | ||||
| $edge_data = array(); | $edge_data = array(); | ||||
| foreach ($project_phids as $project_phid) { | foreach ($project_phids as $project_phid) { | ||||
| if (!is_scalar($project_phid)) { | if (!is_scalar($project_phid)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $edge_data[$project_phid] = array( | $edge_data[$project_phid] = array( | ||||
| 'src' => $task_phid, | 'src' => $task_phid, | ||||
| 'type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | 'type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | ||||
| 'dst' => $project_phid, | 'dst' => $project_phid, | ||||
| ); | ); | ||||
| } | } | ||||
| return $edge_data; | return $edge_data; | ||||
| } | } | ||||