[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/patches/ -> 20131205.buildstepordermig.php (source)

   1  <?php
   2  
   3  $table = new HarbormasterBuildPlan();
   4  $conn_w = $table->establishConnection('w');
   5  $viewer = PhabricatorUser::getOmnipotentUser();
   6  
   7  // Since HarbormasterBuildStepQuery has been updated to handle the
   8  // correct order, we can't use the built in database access.
   9  
  10  foreach (new LiskMigrationIterator($table) as $plan) {
  11    $planname = $plan->getName();
  12    echo "Migrating steps in {$planname}...\n";
  13  
  14    $rows = queryfx_all(
  15      $conn_w,
  16      'SELECT id, sequence FROM harbormaster_buildstep '.
  17      'WHERE buildPlanPHID = %s '.
  18      'ORDER BY id ASC',
  19      $plan->getPHID());
  20  
  21    $sequence = 1;
  22    foreach ($rows as $row) {
  23      $id = $row['id'];
  24      $existing = $row['sequence'];
  25      if ($existing != 0) {
  26        echo "  - {$id} (already migrated)...\n";
  27        continue;
  28      }
  29      echo "  - {$id} to position {$sequence}...\n";
  30      queryfx(
  31        $conn_w,
  32        'UPDATE harbormaster_buildstep '.
  33        'SET sequence = %d '.
  34        'WHERE id = %d',
  35        $sequence,
  36        $id);
  37      $sequence++;
  38    }
  39  }
  40  
  41  echo "Done.\n";


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