You are here

function twitter_post_update_7503 in Twitter 7.6

Add the missing 'account' field.

File

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

Code

function twitter_post_update_7503() {

  // Get the list of fields.
  $types = array(
    'twitter_post',
  );
  $fields = array();
  foreach (field_info_fields() as $field) {
    if (in_array($field['type'], $types)) {
      $fields[] = $field;
    }
  }
  if (!empty($fields)) {
    $spec = array(
      'description' => "Unique identifier for the {twitter_account} this tweet is posting from to.",
      'type' => 'int',
      'unsigned' => TRUE,
      'size' => 'big',
      'not null' => FALSE,
      'default' => 0,
    );
    foreach ($fields as $field) {
      $tables = array(
        _field_sql_storage_tablename($field),
        _field_sql_storage_revision_tablename($field),
      );
      foreach ($tables as $table) {
        $column = $field['field_name'] . '_account';
        db_add_field($table, $column, $spec);
      }
    }
    return t('Added the missing "account" field.');
  }
}