How to rename a field with hook_ds_fields_info() In a contrib module I maintain, I define a DS field via hook_ds_fields_info().

Now it happens that I want to rename this field (the machine name).
(actually it is not about renaming but splitting the one field into multiple fields, but that's a detail)

The first step is trivial: Rename the machine key in hook_ds_fields_info().

Next step, in hook_update_N():
Every entity view mode that uses the field with the old name, should be updated to use the field with the new name instead.

How would I implement this second step?

It seems that the ds_field_settings and ds_layout_settings db tables are what I need to look at. But is this enough? Which API functions could I use?
I managed to implement this, thanks to @aspilicious.

See
- https://drupal.org/node/2190599
- http://drupalcode.org/project/views_content_ds.git/blob/refs/heads/7.x-2.x:/views_content_ds.install

The solution is to edit this directly in the database, with db_update() called from hook_update_N().

The tables are ds_field_settings and ds_layout_settings. Columns you need (same for both tables):


'id' is the primary key. Typical value: taxonomy_term|categories|full
'settings' holds the settings (field settings or layout settings), serialized.


Use drush sqlc + describe (table) to look at the table structure.

It also helps to implement the upgrade as a drush command, ideally with a downgrade option. This allows to quickly test this a lot of times, which is not that easy with hook_update_N().