[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/patches/ -> liskcounters.php (source)

   1  <?php
   2  
   3  // Switch PhabricatorWorkerActiveTask from autoincrement IDs to counter IDs.
   4  // Set the initial counter ID to be larger than any known task ID.
   5  
   6  $active_table = new PhabricatorWorkerActiveTask();
   7  $archive_table = new PhabricatorWorkerArchiveTask();
   8  
   9  $old_table = 'worker_task';
  10  
  11  $conn_w = $active_table->establishConnection('w');
  12  
  13  $active_auto = head(queryfx_one(
  14    $conn_w,
  15    'SELECT auto_increment FROM information_schema.tables
  16      WHERE table_name = %s
  17      AND table_schema = DATABASE()',
  18    $old_table));
  19  
  20  $active_max = head(queryfx_one(
  21    $conn_w,
  22    'SELECT MAX(id) FROM %T',
  23    $old_table));
  24  
  25  $archive_max = head(queryfx_one(
  26    $conn_w,
  27    'SELECT MAX(id) FROM %T',
  28    $archive_table->getTableName()));
  29  
  30  $initial_counter = max((int)$active_auto, (int)$active_max, (int)$archive_max);
  31  
  32  queryfx(
  33    $conn_w,
  34    'INSERT INTO %T (counterName, counterValue)
  35      VALUES (%s, %d)
  36      ON DUPLICATE KEY UPDATE counterValue = %d',
  37    LiskDAO::COUNTER_TABLE_NAME,
  38    $old_table,
  39    $initial_counter + 1,
  40    $initial_counter + 1);


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