[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/patches/ -> 20130926.dinline.php (source)

   1  <?php
   2  
   3  $revision_table = new DifferentialRevision();
   4  $conn_w = $revision_table->establishConnection('w');
   5  $conn_w->openTransaction();
   6  
   7  $src_table = 'differential_inlinecomment';
   8  $dst_table = 'differential_transaction_comment';
   9  
  10  echo "Migrating Differential 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    $revision_id = $row['revisionID'];
  21  
  22    echo "Migrating inline #{$id} (D{$revision_id})...\n";
  23  
  24    $revision_row = queryfx_one(
  25      $conn_w,
  26      'SELECT phid FROM %T WHERE id = %d',
  27      $revision_table->getTableName(),
  28      $revision_id);
  29    if (!$revision_row) {
  30      continue;
  31    }
  32  
  33    $revision_phid = $revision_row['phid'];
  34  
  35    if ($row['commentID']) {
  36      $xaction_phid = PhabricatorPHID::generateNewPHID(
  37        PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
  38        DifferentialRevisionPHIDType::TYPECONST);
  39    } else {
  40      $xaction_phid = null;
  41    }
  42  
  43    $comment_phid = PhabricatorPHID::generateNewPHID(
  44      PhabricatorPHIDConstants::PHID_TYPE_XCMT,
  45      DifferentialRevisionPHIDType::TYPECONST);
  46  
  47    queryfx(
  48      $conn_w,
  49      'INSERT IGNORE INTO %T
  50        (id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
  51          commentVersion, content, contentSource, isDeleted,
  52          dateCreated, dateModified, revisionPHID, changesetID,
  53          isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID)
  54        VALUES (%d, %s, %ns, %s, %s, %s,
  55          %d, %s, %s, %d,
  56          %d, %d, %s, %nd,
  57          %d, %d, %d, %d, %nd)',
  58      $dst_table,
  59  
  60      // id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy
  61      $row['id'],
  62      $comment_phid,
  63      $xaction_phid,
  64      $row['authorPHID'],
  65      'public',
  66      $row['authorPHID'],
  67  
  68      // commentVersion, content, contentSource, isDeleted
  69      1,
  70      $row['content'],
  71      $content_source,
  72      0,
  73  
  74      // dateCreated, dateModified, revisionPHID, changesetID
  75      $row['dateCreated'],
  76      $row['dateModified'],
  77      $revision_phid,
  78      $row['changesetID'],
  79  
  80      // isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID
  81      $row['isNewFile'],
  82      $row['lineNumber'],
  83      $row['lineLength'],
  84      0,
  85      $row['commentID']);
  86  
  87  }
  88  
  89  $conn_w->saveTransaction();
  90  echo "Done.\n";


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