Base table or view not found: 1146 Table '(database).(entity)__(field_name)' doesn't exist

I have problems running my site since i deleted field (field_name) from entity (entity), to be clear entity was created from ContentEntityType.

What kind of field is it, if it has it's own table and those two underscores in table name?

How can i create field of this kind to solve this error?

It is quite urgent and my bad is i don't have any database backups.

  • How did you delete the field? – hotwebmatter Oct 17 '19 at 20:30

Found the fix!!! (Yes, i am user96758)

After 3 hours of investigation, internet and uncle Google wasn't helpfull at all.

The problem was that field was created via Drupal UI in Content Type -> Manage fields. And it was deleted programatically by using UPDATE (code example below), not by using UI.

function hook_update_N(&$sandbox){
    $update_manager = Drupal::service('entity.definition_update_manager');
    $definition = $update_manager->getFieldStorageDefinition('field_name', 'entity_id');
    return t('Entity: field was uninstalled');

I have installed module named "Devel", which is pretty good damn module and every developer should have it.

I was finding anything that contains name of my problematic field.

Thanks to Devel module i was able to find config of this field. Usually you can see all configs at url (your_site)/devel/config

Well, i was desperate, so the last chance was to delete the config i found. Usually the fields are named: field.field.(entity).(entity).(field_name)

I removed the config with this code below



| improve this answer | |
  • So, if i can ask someone to set this question as "Solved". Thanks again :) – Pavel Meduna Oct 17 '19 at 23:45
  • To mark the question as solved, log in as user96758 and accept your answer. – hotwebmatter Oct 20 '19 at 7:43

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.