You are here

function ultimate_cron_update_6003 in Ultimate Cron 6

Switch from fid to function name in ultimate_cron_log

File

./ultimate_cron.install, line 241
Installation file for Ultimate Cron

Code

function ultimate_cron_update_6003() {
  $ret = array();
  db_add_field($ret, 'ultimate_cron_log', 'function', array(
    'description' => 'Function name',
    'type' => 'varchar',
    'length' => 127,
    'not null' => TRUE,
    'initial' => 'function',
  ));
  $fids = db_query("SELECT DISTINCT fid FROM {ultimate_cron_log}");
  while ($fid = db_fetch_object($fids)) {
    $function = db_result(db_query("SELECT `function` FROM {ultimate_cron} WHERE fid = %d", $fid->fid));
    $ret[] = update_sql("UPDATE {ultimate_cron_log} SET `function` = '" . $function . "' WHERE fid = " . $fid->fid);
  }
  db_drop_field($ret, 'ultimate_cron_log', 'fid');
  db_drop_index($ret, 'ultimate_cron_log', 'idx_last');
  db_drop_index($ret, 'ultimate_cron_log', 'idx_count');
  db_add_index($ret, 'ultimate_cron_log', 'idx_last', array(
    'function',
    'start',
  ));
  db_add_index($ret, 'ultimate_cron_log', 'idx_count', array(
    'function',
    'end',
  ));
  return $ret;
}