You are here

function data_update_6002 in Data 6

Same name and namespace in other branches
  1. 7 data.install \data_update_6002()

Add a primary key, required by CTools. Shorten name key to 128 char max.

File

./data.install, line 91
Install hooks for Data module.

Code

function data_update_6002() {
  $ret = array();
  db_drop_index($ret, 'data_tables', 'name');
  $spec = array(
    'type' => 'varchar',
    'length' => '128',
    'not null' => TRUE,
    'default' => '',
    'description' => 'Table name.',
  );
  db_change_field($ret, 'data_tables', 'name', 'name', $spec);
  db_add_primary_key($ret, 'data_tables', array(
    'name',
  ));

  // reset cTools static cache of this table; otherwise it throws an error about
  // lacking a primary key, which just adds insult to injury as we're trying to fix that!
  drupal_get_schema('data_tables', TRUE);
  if (function_exists('ctools_static_reset')) {
    ctools_static_reset('ctools_export_get_schema');
  }
  return $ret;
}