12

I have a content-type with 4 fields each of which is a term reference. There are 100 nodes each assigned 4 term references. I have accidentally deleted one of these fields from the admin>structure>content-types>mycontent-type...resulting in all 100 nodes losing the term reference this lost field contained.

After installing the Database Admin module I could see that the database for my deleted field was still present, it had been renamed to something like "field_deleted_field_74"

  1. Using mysql I have been able to rename this database back to "field_data_field_originalname" - i.e. using the original machine name for the deleted field
  2. Furthermore I have been able to switch the value of the deleted column inside this database from '1' to '0'.

I have done the above with the other 'ghost' database that I found that was called something like "field_revision_field_74" ...

My problem now is that my renamed field is not appearing as a pre-existing field on my content-type manage fields display nor at admin>reports>fields list. When I run 'drush field-info fields' it is also missing.

How to I bring it back? I am assuming that there is another database that refers to it that I need to edit.

Thanks!

2
  • Do you have any backups of the whole database before you deleted the fields?
    – Ollie
    Commented Mar 24, 2014 at 21:20
  • Unfortunately not. I did however solve the problem. Commented Mar 24, 2014 at 21:48

1 Answer 1

15

A good question, and surprising there's not an easier way to rollback a deleted field, given the data is still available.

Assuming you have:

  1. Renamed the field_deleted_* tables back to field_data_field_myfield and field_revision_field_myfield (latter also important)
  2. Updated the 'deleted' flag from 1 to 0 in the relevant data tables.

There is also

  • field_config

The main field configuration

  • field_config_instance

The field configuration on a particular entity bundle.

You may need to adjust the 'deleted' flag there also:

e.g:

UPDATE field_config SET deleted = 0 where field_name = 'field_my_deleted_field';
UPDATE field_config_instance SET deleted = 0 where field_name = 'field_my_deleted_field';
TRUNCATE TABLE cache_field;
1
  • 2
    Thank you for the quick response. Editing both the field_config and field_config_instance databases did the trick. Commented Mar 24, 2014 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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