1

I've been using Feature to provision changes between my DEV, STAGING and LIVE sites.

What I'm finding is when I make a field redundant on a node type on my DEV site, features does not automatically delete is on my STAGING site.

For example: I originally had a field called Key Contact in my Basic Page node type. I created a feature which I uploaded to my STAGING site, the Key Contact field was created and it worked fine.

However, that same field is now redundant. I have deleted it on my DEV site. I re-created the Feature and uploaded to my STAGING site.

The problem is the Key Contact field still exists on the STAGING version of my website.

Can anyone give me some direction to get Features to not just create new fields but remove fields I have deleted on DEV - so I don't have to delete a lot of fields manually on both STAGING and eventually the LIVE site?

  • 1
    Features automatically deleting fields seems like an extremely dangerous feature to me, and I think there is good reason for it not to happen. I would probably go about it by deploying update hooks along with the features changes. – Letharion Jul 25 '14 at 11:07
1

As declared in https://www.drupal.org/node/649298#comment-7710069 there won't be any such support in Features module itself. In the same issue, there is also relevant answer in https://www.drupal.org/node/649298#comment-10219951:

You can instead add a hook_update_N function to a custom module and delete the field with code (see field_delete_field).

This should be used in my_feature.install file. Note that if you go this way, you will probably need to add something like

function my_feature_features_export_files($module_name, $export) {
  if ($module_name == 'my_feature') {
    return array('my_feature.install' => array('file_path' => 'sites/all/modules/my_feature/my_feature.install'));
  }
}

to you my_feature.module file. This ensures that my_feature.install file is added to feature on any further export.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.