I am deploying a site using hook_update_n()s to several environments. I revert features like this:

/**
 * Create a new field called xyz
 */
function MYMODULE_update_7043() {
  features_revert(array('my_feature' => array('field')));
}

On one of my environments, the update does not go through, giving me the error:

The table <em class="placeholder">field_data_field_xyz</em> already exists .                                                                [error]

Does anyone have any suggestions on how to debug this? If features thinks the table does not exist and tries to create it, yet for some reason, on one particular environment the table does already exist, what is my best course of action?
Is there a way to tell features that a table really does exist for a given field; therefore not to try to create it?

Comments

alberto56’s picture

Status: Active » Fixed

This happens if the field does not exist (it is not in the list returned by field_info_fields()), but its data field and/or data field revision fields are present (e.g. field_data_field_my_field or field_revision_field_my_field). In this case the function field_base_features_rebuild() in sites/*modules/contrib/features/includes/features.field.inc calls field_info_fields(), and because the field does not exist, Features tries to create it (field_create_field(field_my_field)). Core, then, tries to create the field, but throws an exception when trying to create related tables.

Solutions

(1) Make sure there is no important data in the related tables

drush sqlc
> select * from field_data_field_my_field;
> select * from field_revision_field_my_field;

If the result is empty or contains data you can live without,

drush sqlc
> drop table field_data_field_my_field;
> drop table field_revision_field_my_field;

Everything should now work.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dvmanjunath’s picture

Issue summary: View changes

i'm facing same issue. After deleting tables manually, reverted the feature but no luck. The problem is fields are not created but field specific tables created in DB.

mbatterton’s picture

Hi alterbto56, thank you for your suggestion this worked perfectly.