From 71841e262abd9566dc8437184c88dd60b25ef3e2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 28 Jul 2013 16:55:13 -0700 Subject: [PATCH] Migrate Ponder comments to ApplicationTransactions Summary: Ref T3373. Bring the storage across. Test Plan: {F52067} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3373 Differential Revision: https://secure.phabricator.com/D6606 --- .../sql/patches/20130728.ponderxcomment.php | 86 +++++++++++++++++++ .../PonderQuestionViewController.php | 2 + .../patch/PhabricatorBuiltinPatchList.php | 4 + 3 files changed, 92 insertions(+) create mode 100644 resources/sql/patches/20130728.ponderxcomment.php diff --git a/resources/sql/patches/20130728.ponderxcomment.php b/resources/sql/patches/20130728.ponderxcomment.php new file mode 100644 index 0000000000..9f57b7bdce --- /dev/null +++ b/resources/sql/patches/20130728.ponderxcomment.php @@ -0,0 +1,86 @@ +establishConnection('w'); +$conn_w->openTransaction(); + +echo "Migrating Ponder comments to ApplicationTransactions...\n"; + +$rows = new LiskRawMigrationIterator($conn_w, 'ponder_comment'); +foreach ($rows as $row) { + + $id = $row['id']; + echo "Migrating {$id}...\n"; + + $type = phid_get_type($row['targetPHID']); + switch ($type) { + case PonderPHIDTypeQuestion::TYPECONST: + $table_obj = $qtable; + $comment_obj = new PonderQuestionTransactionComment(); + break; + case PonderPHIDTypeAnswer::TYPECONST: + $table_obj = $atable; + $comment_obj = new PonderAnswerTransactionComment(); + break; + } + + $comment_phid = PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_XACT, + $type); + + $xaction_phid = PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_XACT, + $type); + + queryfx( + $conn_w, + 'INSERT INTO %T (phid, transactionPHID, authorPHID, viewPolicy, editPolicy, + commentVersion, content, contentSource, isDeleted, dateCreated, + dateModified) + VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d)', + $comment_obj->getTableName(), + $comment_phid, + $xaction_phid, + $row['authorPHID'], + 'public', + $row['authorPHID'], + 1, + $row['content'], + PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_LEGACY, + array())->serialize(), + 0, + $row['dateCreated'], + $row['dateModified']); + + queryfx( + $conn_w, + 'INSERT INTO %T (phid, authorPHID, objectPHID, viewPolicy, editPolicy, + commentPHID, commentVersion, transactionType, oldValue, newValue, + contentSource, metadata, dateCreated, dateModified) + VALUES (%s, %s, %s, %s, %s, %s, %d, %s, %ns, %ns, %s, %s, %d, %d)', + $table_obj->getTableName(), + $xaction_phid, + $row['authorPHID'], + $row['targetPHID'], + 'public', + $row['authorPHID'], + $comment_phid, + 1, + PhabricatorTransactions::TYPE_COMMENT, + 'null', + 'null', + PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_LEGACY, + array())->serialize(), + '[]', + $row['dateCreated'], + $row['dateModified']); + +} + +$conn_w->saveTransaction(); + +echo "Done.\n"; diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php index 9f8536c8a0..a8b34d5d8f 100644 --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -124,6 +124,8 @@ final class PonderQuestionViewController extends PonderController { ->setUser($viewer) ->setObject($question); + $this->loadHandles(array($question->getAuthorPHID())); + $view->addProperty( pht('Status'), PonderQuestionStatus::getQuestionStatusFullName($question->getStatus())); diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index 31c0bc49f6..d74e42f241 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1495,6 +1495,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('20130728.ponderuniquekey.sql'), ), + '20130728.ponderxcomment.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath('20130728.ponderxcomment.php'), + ), ); } }