2

I wanted to delete a filed named MyField.

So I first deleted the corresponding record for MyField in field_config table and field_config_instance table.

And now I'm trying to drop these tables by using phpmyadmin.

field_data_field_MyField
field_revision_field_MyField

But even if I drop them they are still there. It seems that they can't be droped.

Isn't it possible to delete fields directly in DB?

3

@hampercm explained why directly deleting records and tables from database is not recommended. It is so true that everyone is encouraged to use admin UI or Drupal API to remove the fields and field instances.

But, I guess you know what the best practise is and wanna do that by SQL query with some reason (e.g. company policy. YES, I faced this stupid requirement before)

You are on the right track. Drupal save field and field instances config in field_config and field_config_instance. BUT, Drupal also cache these data in cache table.

So, you need to truncate the cache table.

2

Attempting to deleting fields by dropping the database tables is not recommended. It's likely Drupal is recreating those tables when it discovers they're missing; that's why you can't seem to delete them.

The recommended way of deleting fields in Drupal is to remove them from all Content Types that use them using the Fields UI (the "manage fields" links from admin/structure/types). Then, Drupal will automatically clean up the DB tables during a future Cron run.

Note: this answer assumes you added the fields manually to one or more Content Types. If you instead did so by defining a Content Type programmatically (i.e. you created a custom module to define it), different steps will be needed.

  • Thanks for letting me know that. Next time I'll do so. But unfortunately I have already deleted them in field_config and field_config_instance this time ;) – Sona7 Aug 14 '16 at 2:42

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.