You are here

function link_update_6001 in Link 6.2

Same name and namespace in other branches
  1. 6 link.install \link_update_6001()

Change the database schema to allow NULL values.

File

./link.install, line 70
Install file for the link module.

Code

function link_update_6001() {
  $ret = array();

  // Build a list of fields that need updating.
  $update_fields = array();
  foreach (content_types_install() as $type_name => $fields) {
    foreach ($fields as $field) {
      if ($field['type'] == 'link') {

        // We only process a given field once.
        $update_fields[$field['field_name']] = $field;
      }
    }
  }

  // Update each field's storage to match the current definition.
  foreach ($update_fields as $field) {
    $db_info = content_database_info($field);
    foreach ($db_info['columns'] as $column) {
      db_change_field($ret, $db_info['table'], $column['column'], $column['column'], $column);
      $ret[] = update_sql("UPDATE {" . $db_info['table'] . "} SET " . $column['column'] . " = NULL WHERE " . $column['column'] . " = '' OR " . $column['column'] . " = 'N;'");
    }
  }

  // Let CCK re-associate link fields with Link module and activate the fields.
  content_associate_fields('link');
  return $ret;
}