For a recent project I was tasked with migrating the old Twitter 1.0 API widget to the new Twitter embedded timeline functionality.
The original field was a simple 255 character textfield:
This obviously would not hold the multi-line, roughly 500 character content of the new Twitter embedded timeline. So a change was required in order to extent the size of this field.
It is true, that you can simply delete the field, and then create a new one, with a new name. I chose instead to retain the existing field (and it’s content), this way content authors would know what content used to be in the old textfield prior to conversion.
Update hook to the rescue
Update hooks in Drupal can be used to perform one time database manipulations. This makes them ideal for this type of change.
Here is the entire update hook that was written (the field name was
To walk through this update hook, one step at a time:
This alters the field configuration and changes the type to be a textarea (changed from a textfield).
This (along with the next SQL query) alters the size of the data storage column in both the field data and field revision tables. Be careful to choose a size that is allowed by your database.
This clears Drupal’s internal cache for the fields
Finally, you can revert your feature on top. This requires you to have exported the content type (and it’s fields) with features. This allows you to for instance change the title and description of the field.
Here is a screenshot that shows the newly converted textarea, including new title and description
Drupal certainly does you no favours when it comes to field conversion with existing content already in those fields, luckily there still exist ways to get this done, in a cross database fashion.
Let me know if you have done similar conversions (rather than replacements), and how you went about that.