Changeset 13154

Show
Ignore:
Timestamp:
12/30/11 18:24:23 (1 year ago)
Author:
p_lindheimer
Message:

adds migration for did field in cdr table and removed some stupid stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/upgrades/2.10.0beta3/migration.php

    r13150 r13154  
    2828} 
    2929 
    30 // added again here for alpha testerd uprgrading 
    31 $sql = "SELECT sortorder FROM freepbx_settings"; 
    32 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    33 if (DB::IsError($confs)) { // no error... Already done 
    34   $sql = "ALTER TABLE freepbx_settings ADD sortorder INT ( 11 ) NOT NULL DEFAULT 0"; 
    35   $results = $db->query($sql); 
    36   if(DB::IsError($results)) { 
    37     die($results->getMessage()); 
    38   } 
    39   out("Added field sortorder to freepbx_settings"); 
    40 
    41  
    42 // Need to migrate the CDR table adding the recordingfile field. We get the creds from cdr_mysql.conf 
     30// Need to migrate the CDR table adding the recordingfile and did field. We get the creds from cdr_mysql.conf 
    4331// since $amp_conf is not really authoritative. 
    4432// 
     
    5846  $db_cdr = DB::connect($datasource); // attempt connection 
    5947 
    60   $sql = "desc cdr"; 
    61   $sql = "select * from cdr"; 
    62     //$results = $db_cdr->query($sql); 
    63     $results = $db_cdr->getAll($sql); 
    64  
    6548  $sql = "SELECT recordingfile FROM cdr"; 
    6649  $confs = $db_cdr->getRow($sql, DB_FETCHMODE_ASSOC); 
    6750  outn(_("checking if recordingfile file field needed in cdr..")); 
    6851  if (DB::IsError($confs)) { // no error... Already done 
    69      $sql = "ALTER TABLE cdr ADD recordingfile VARCHAR ( 255 )"; 
     52   $sql = "ALTER TABLE cdr ADD recordingfile VARCHAR ( 255 ) NOT NULL default ''"; 
    7053    $results = $db_cdr->query($sql); 
    7154    if(DB::IsError($results)) { 
    7255      out(_("failed")); 
    73       freepbx_log(FPBX_LOG_ERROR,"failed to add recordingfile filed to cdr table during migration"); 
     56      freepbx_log(FPBX_LOG_ERROR,"failed to add recordingfile fieled to cdr table during migration"); 
     57    } 
     58    out(_("added")); 
     59  } else { 
     60    out(_("already there")); 
     61  } 
     62 
     63  $sql = "SELECT did FROM cdr"; 
     64  $confs = $db_cdr->getRow($sql, DB_FETCHMODE_ASSOC); 
     65  outn(_("checking if did file field needed in cdr..")); 
     66  if (DB::IsError($confs)) { // no error... Already done 
     67    $sql = "ALTER TABLE cdr ADD did VARCHAR ( 50 ) NOT NULL default ''"; 
     68    $results = $db_cdr->query($sql); 
     69    if(DB::IsError($results)) { 
     70      out(_("failed")); 
     71      freepbx_log(FPBX_LOG_ERROR,"failed to add did fieled to cdr table during migration"); 
    7472    } 
    7573    out(_("added"));