You are here

function nodereference_update_6000 in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 6.3 modules/nodereference/nodereference.install \nodereference_update_6000()
  2. 6.2 modules/nodereference/nodereference.install \nodereference_update_6000()

All fields must allow NULL values to indicate empty fields.

File

modules/nodereference/nodereference.install, line 42

Code

function nodereference_update_6000() {
  $ret = array();
  include_once './' . drupal_get_path('module', 'content') . '/content.module';
  content_clear_type_cache();
  include_once './' . drupal_get_path('module', 'content') . '/content.install';
  $types = content_types_install();
  foreach ($types as $type_name => $fields) {
    foreach ($fields as $field) {
      switch ($field['type']) {
        case 'nodereference':
          $db_info = content_database_info($field);
          $table = $db_info['table'];
          $column = $db_info['columns']['nid']['column'];
          db_change_field($ret, $table, $column, $column, array(
            'type' => 'int',
            'not null' => FALSE,
          ));
          db_field_set_no_default($ret, $db_info['table'], $column);
          $ret[] = update_sql("UPDATE {" . $db_info['table'] . "} SET " . $column . " = NULL WHERE " . $column . " = 0");
      }
    }
  }
  return $ret;
}