[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/autopatches/ -> 20140210.herald.rule-condition-mig.php (source)

   1  <?php
   2  
   3  $table = new HeraldCondition();
   4  $conn_w = $table->establishConnection('w');
   5  
   6  echo "Migrating Herald conditions of type Herald rule from IDs to PHIDs...\n";
   7  foreach (new LiskMigrationIterator($table) as $condition) {
   8    if ($condition->getFieldName() != HeraldAdapter::FIELD_RULE) {
   9      continue;
  10    }
  11  
  12    $value = $condition->getValue();
  13    if (!is_numeric($value)) {
  14      continue;
  15    }
  16    $id = $condition->getID();
  17    echo "Updating condition {$id}...\n";
  18  
  19    $rule = id(new HeraldRuleQuery())
  20      ->setViewer(PhabricatorUser::getOmnipotentUser())
  21      ->withIDs(array($value))
  22      ->executeOne();
  23  
  24    queryfx(
  25      $conn_w,
  26      'UPDATE %T SET value = %s WHERE id = %d',
  27      $table->getTableName(),
  28      json_encode($rule->getPHID()),
  29      $id);
  30  }
  31  echo "Done.\n";


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