Presumably you will want to know which fields need updating, possibly to do some logging or checks on the data. To do this, get all table and column names that contain a _format
column:
select distinct TABLE_NAME, column_name
from information_schema.columns
where TABLE_SCHEMA = 'my_drupal_database_name' and column_name like '%_format';
Armed with this data you can build separate queries from those values. Check the output first; you may need to remove some entries that do not pertain to content/revisions. I recommend using a regex-capable editor to build the queries. I turned the data into a big select [...] union
statement and then ran update queries against it.
Using this approach saved me quite some time when I needed to update thousands of nodes/revisions. Remember to clear the field cache (NOT covered by drush cc all
!):
field_cache_clear();
Or with drush:
drush sqlq "truncate table cache_field;"
Also removing text filter
If you are also retiring a text filter, afterwards you will need to change the default text format for CTs that had fields that used it. If you don't do this, your users will get permission denied messages within the fields that used the old_format
. I did this query to find the culprits:
select * from field_config_instance where `data` LIKE '%old_format%';
To make the changes, I found it easier to use the interface to visit each field settings page and press Save (the data is stored as longblob and was unwieldy to search and replace due to the better formats module data injections). Even fields that had Text processing set to Plain text
contained the old_format! For the fields that have Text processing set to Filtered text (user selects text format)
, you will additionally need to select a new default value and press Save.
You should clear the filter cache after removing a filter (again, not covered by drush cc all
!):
cache_clear_all('*', 'cache_filter', TRUE);
Or with drush:
drush sqlq "truncate table cache_filter;"