[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/autopatches/ -> 20140722.audit.4.migtext.php (source)

   1  <?php
   2  
   3  $conn_w = id(new PhabricatorAuditTransaction())->establishConnection('w');
   4  $rows = new LiskRawMigrationIterator($conn_w, 'audit_comment');
   5  
   6  $content_source = PhabricatorContentSource::newForSource(
   7    PhabricatorContentSource::SOURCE_LEGACY,
   8    array())->serialize();
   9  
  10  echo "Migrating Audit comment text to modern storage...\n";
  11  foreach ($rows as $row) {
  12    $id = $row['id'];
  13    echo "Migrating Audit comment {$id}...\n";
  14    if (!strlen($row['content'])) {
  15      echo "Comment has no text, continuing.\n";
  16      continue;
  17    }
  18  
  19    $xaction_phid = PhabricatorPHID::generateNewPHID(
  20      PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
  21      PhabricatorRepositoryCommitPHIDType::TYPECONST);
  22  
  23    $comment_phid = PhabricatorPHID::generateNewPHID(
  24      PhabricatorPHIDConstants::PHID_TYPE_XCMT,
  25      PhabricatorRepositoryCommitPHIDType::TYPECONST);
  26  
  27    queryfx(
  28      $conn_w,
  29      'INSERT IGNORE INTO %T
  30        (phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
  31          commentVersion, content, contentSource, isDeleted,
  32          dateCreated, dateModified, commitPHID, pathID,
  33          legacyCommentID)
  34        VALUES (%s, %s, %s, %s, %s,
  35          %d, %s, %s, %d,
  36          %d, %d, %s, %nd,
  37          %d)',
  38      'audit_transaction_comment',
  39  
  40      // phid, transactionPHID, authorPHID, viewPolicy, editPolicy
  41      $comment_phid,
  42      $xaction_phid,
  43      $row['actorPHID'],
  44      'public',
  45      $row['actorPHID'],
  46  
  47      // commentVersion, content, contentSource, isDeleted
  48      1,
  49      $row['content'],
  50      $content_source,
  51      0,
  52  
  53      // dateCreated, dateModified, commitPHID, pathID, legacyCommentID
  54      $row['dateCreated'],
  55      $row['dateModified'],
  56      $row['targetPHID'],
  57      null,
  58      $row['id']);
  59  }
  60  
  61  echo "Done.\n";


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1