You are here

function webform_update_6001 in Webform 6.3

Same name and namespace in other branches
  1. 6.2 webform.install \webform_update_6001()

Upgrade to Drupal 6. Convert submissions sid column to auto-increment.

File

./webform.install, line 508
Webform module install/schema hooks.

Code

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

  // Keys must be dropped before altering the column.
  db_drop_primary_key($ret, 'webform_submissions');
  db_drop_unique_key($ret, 'webform_submissions', 'sid_nid');

  // Alter to a primary key and add the unique key back.
  db_change_field($ret, 'webform_submissions', 'sid', 'sid', array(
    'type' => 'serial',
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'sid',
    ),
  ));
  db_add_unique_key($ret, 'webform_submissions', 'sid_nid', array(
    'sid',
    'nid',
  ));
  return $ret;
}