| | 29 | |
|---|
| | 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 |
|---|
| | 43 | // since $amp_conf is not really authoritative. |
|---|
| | 44 | // |
|---|
| | 45 | $db_creds = parse_ini_file($amp_conf['ASTETCDIR'] . '/cdr_mysql.conf'); |
|---|
| | 46 | if ($db_creds === false) { |
|---|
| | 47 | out(_("Error parsing cdr_mysql.conf no migration done")); |
|---|
| | 48 | } else { |
|---|
| | 49 | $db_creds['hostname'] = !empty($db_creds['hostname']) ? $db_creds['hostname'] : 'localhost'; |
|---|
| | 50 | $datasource = 'mysql://' |
|---|
| | 51 | . $db_creds['user'] |
|---|
| | 52 | . ':' |
|---|
| | 53 | . $db_creds['password'] |
|---|
| | 54 | . '@' |
|---|
| | 55 | . $db_creds['hostname'] |
|---|
| | 56 | . '/' |
|---|
| | 57 | . $db_creds['dbname']; |
|---|
| | 58 | $db_cdr = DB::connect($datasource); // attempt connection |
|---|
| | 59 | |
|---|
| | 60 | $sql = "desc cdr"; |
|---|
| | 61 | $sql = "select * from cdr"; |
|---|
| | 62 | //$results = $db_cdr->query($sql); |
|---|
| | 63 | $results = $db_cdr->getAll($sql); |
|---|
| | 64 | |
|---|
| | 65 | $sql = "SELECT recordingfile FROM cdr"; |
|---|
| | 66 | $confs = $db_cdr->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 67 | outn(_("checking if recordingfile file field needed in cdr..")); |
|---|
| | 68 | if (DB::IsError($confs)) { // no error... Already done |
|---|
| | 69 | $sql = "ALTER TABLE cdr ADD recordingfile VARCHAR ( 255 )"; |
|---|
| | 70 | $results = $db_cdr->query($sql); |
|---|
| | 71 | if(DB::IsError($results)) { |
|---|
| | 72 | out(_("failed")); |
|---|
| | 73 | freepbx_log(FPBX_LOG_ERROR,"failed to add recordingfile filed to cdr table during migration"); |
|---|
| | 74 | } |
|---|
| | 75 | out(_("added")); |
|---|
| | 76 | } else { |
|---|
| | 77 | out(_("already there")); |
|---|
| | 78 | } |
|---|
| | 79 | } |
|---|