function twitter_post_update_7502 in Twitter 7.6
Change the 'message' field to a BLOB.
File
- twitter_post/
twitter_post.install, line 158 - Install, update and uninstall functions for the twitter module.
Code
function twitter_post_update_7502() {
// 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' => "The text of the Twitter post.",
// Using a blob instead of a text type make it possible for MySQL to
// handle extended UTF8 characters, like emoji.
// @see https://www.drupal.org/node/1910376
'type' => 'blob',
// Balance size vs performance. The August 2015 update allows for DMs
// that are 10,000 characters in length, so in theory MySQL's default
// blob length of 16KB should be enough.
'size' => 'normal',
'not null' => FALSE,
);
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'] . '_message';
if (db_field_exists($table, $column)) {
db_change_field($table, $column, $column, $spec);
}
else {
db_add_field($table, $column, $spec);
}
}
}
return t('Converted the "message" field to BLOB.');
}
}