You are here

function twitter_update_6004 in Twitter 6.3

Same name and namespace in other branches
  1. 6.5 twitter.install \twitter_update_6004()
  2. 6.2 twitter.install \twitter_update_6004()
  3. 6.4 twitter.install \twitter_update_6004()

Add NOT NULL constraint and DEFAULT value to the screen_name field of the twitter and twitter_user tables per updated schema definition.

See http://drupal.org/node/336048 and http://drupal.org/node/430442

File

./twitter.install, line 370

Code

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

  // Have to drop PRIMARY KEY and indexes that use the field being changed.
  // twitter
  db_drop_index($ret, 'twitter', 'screen_name');
  db_change_field($ret, 'twitter', 'screen_name', 'screen_name', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ), array(
    'indexes' => array(
      'screen_name' => array(
        'screen_name',
      ),
    ),
  ));

  // twitter_user
  db_drop_index($ret, 'twitter_user', 'screen_name');
  db_drop_primary_key($ret, 'twitter_user');
  db_change_field($ret, 'twitter_user', 'screen_name', 'screen_name', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ), array(
    'primary key' => array(
      'uid',
      'screen_name',
    ),
    'indexes' => array(
      'screen_name' => array(
        'screen_name',
      ),
    ),
  ));
  return $ret;
}