Convert text field to long text field

Public

Convert a text field to a long text field

Get raw version
php
  1. /**
  2.  * Convert text field to textarea field.
  3.  */
  4. function my_custom_module_update_7000() {
  5. db_update('field_config')
  6. ->fields(array('type' => 'text_long'))
  7. ->condition('field_name', 'field_my_text_field')
  8. ->execute();
  9.  
  10. // From text.install for long text fields
  11. $textarea_spec = array(
  12. 'type' => 'text',
  13. 'size' => 'big',
  14. 'not null' => FALSE,
  15. );
  16. db_change_field('field_data_field_my_text_field', 'field_my_text_field_value', 'field_my_text_field_value', $textarea_spec);
  17. db_change_field('field_revision_field_my_text_field', 'field_my_text_field_value', 'field_my_text_field_value', $textarea_spec);
  18. field_cache_clear(TRUE);
  19. }

Comments