You are here

function twitter_update_6505 in Twitter 6.5

Renames twitter_account.added_by_uid to twitter_account.uid.

If the {twitter_account}.uid field already exists, don't do anything.

File

./twitter.install, line 901
Install, update and uninstall functions for the twitter module.

Code

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

  // If there is no {twitter_account}.uid field, add it.
  if (!db_column_exists('twitter_account', 'uid')) {
    $spec = array(
      'description' => "The uid of the user who added this Twitter account",
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
    );

    // If the 'added_by_uid' field exists, as was added by update 6504 and needs
    // to be renamed.
    if (db_column_exists('twitter_account', 'added_by_uid')) {
      db_change_field($ret, 'twitter_account', 'added_by_uid', 'uid', $spec);
    }
    else {
      db_add_field($ret, 'twitter_account', 'uid', $spec);
    }
  }
  return $ret;
}