You are here

function phone_update_6200 in Phone 6

Fixing update : field setting 'not null' => TRUE can cause problems with MySQL in strict mode.

File

./phone.install, line 67
Defines phone number fields for CCK. Installation file

Code

function phone_update_6200() {
  $ret = array();
  module_load_include('inc', 'content', 'includes/content.crud');
  $fields = content_fields();
  foreach ($fields as $field) {
    if (substr($field['type'], 3) == 'phone') {
      $db_info = content_database_info($field);
      if (isset($db_info['columns']['value'])) {
        $table = $db_info['table'];
        $value_column = $db_info['columns']['value']['column'];
        $ret[] = update_sql("ALTER TABLE {" . $table . "} CHANGE " . $value_column . " " . $value_column . " VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
      }
    }
  }
  drupal_set_message("Phone fields have been updated.");
  return $ret;
}