You are here

function content_update_6000 in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 6.3 content.install \content_update_6000()
  2. 6.2 content.install \content_update_6000()

Add module name to fields table to make it easier to identify the fields to delete when a module is uninstalled.

Needed because the value drops out of content_info() when module is disabled, so there is no other way to find the associated fields.

File

./content.install, line 207

Code

function content_update_6000() {
  $ret = array();
  if (db_column_exists(content_field_tablename(), 'active')) {
    return $ret;
  }
  db_add_field($ret, content_field_tablename(), 'module', array(
    'type' => 'varchar',
    'length' => 127,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, content_field_tablename(), 'db_columns', array(
    'type' => 'text',
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, content_field_tablename(), 'active', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_field($ret, content_instance_tablename(), 'widget_module', array(
    'type' => 'varchar',
    'length' => 127,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, content_instance_tablename(), 'widget_active', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));

  // This will update the table for any modules enabled at this time.
  foreach (module_list() as $module) {
    content_associate_fields($module);
  }

  // Fix the cache_content schema
  if (db_table_exists('cache_content')) {
    db_drop_table($ret, 'cache_content');
  }
  db_create_table($ret, 'cache_content', drupal_get_schema_unprocessed('system', 'cache'));
  variable_set('content_schema_version', 6000);

  // The cache table had to be used to store data until this update ran,
  // so clear cache out now that we're switching back to the cache_content table.
  $ret[] = update_sql('DELETE FROM {cache}');
  return $ret;
}