[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/autopatches/ -> 20140722.audit.3.miginlines.php (source)

   1  <?php
   2  
   3  $audit_table = new PhabricatorAuditTransaction();
   4  $conn_w = $audit_table->establishConnection('w');
   5  $conn_w->openTransaction();
   6  
   7  $src_table = 'audit_inlinecomment';
   8  $dst_table = 'audit_transaction_comment';
   9  
  10  echo "Migrating Audit inline comments to new format...\n";
  11  
  12  $content_source = PhabricatorContentSource::newForSource(
  13    PhabricatorContentSource::SOURCE_LEGACY,
  14    array())->serialize();
  15  
  16  $rows = new LiskRawMigrationIterator($conn_w, $src_table);
  17  foreach ($rows as $row) {
  18    $id = $row['id'];
  19  
  20    echo "Migrating inline #{$id}...\n";
  21  
  22    if ($row['auditCommentID']) {
  23      $xaction_phid = PhabricatorPHID::generateNewPHID(
  24        PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
  25        PhabricatorRepositoryCommitPHIDType::TYPECONST);
  26    } else {
  27      $xaction_phid = null;
  28    }
  29  
  30    $comment_phid = PhabricatorPHID::generateNewPHID(
  31      PhabricatorPHIDConstants::PHID_TYPE_XCMT,
  32      PhabricatorRepositoryCommitPHIDType::TYPECONST);
  33  
  34    queryfx(
  35      $conn_w,
  36      'INSERT IGNORE INTO %T
  37        (id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
  38          commentVersion, content, contentSource, isDeleted,
  39          dateCreated, dateModified, commitPHID, pathID,
  40          isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID)
  41        VALUES (%d, %s, %ns, %s, %s, %s,
  42          %d, %s, %s, %d,
  43          %d, %d, %s, %nd,
  44          %d, %d, %d, %d, %nd)',
  45      $dst_table,
  46  
  47      // id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy
  48      $row['id'],
  49      $comment_phid,
  50      $xaction_phid,
  51      $row['authorPHID'],
  52      'public',
  53      $row['authorPHID'],
  54  
  55      // commentVersion, content, contentSource, isDeleted
  56      1,
  57      $row['content'],
  58      $content_source,
  59      0,
  60  
  61      // dateCreated, dateModified, commitPHID, pathID
  62      $row['dateCreated'],
  63      $row['dateModified'],
  64      $row['commitPHID'],
  65      $row['pathID'],
  66  
  67      // isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID
  68      $row['isNewFile'],
  69      $row['lineNumber'],
  70      $row['lineLength'],
  71      0,
  72      $row['auditCommentID']);
  73  
  74  }
  75  
  76  $conn_w->saveTransaction();
  77  echo "Done.\n";


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