After deploying a Drupal 8 site to a new server, we have the problem of an old deleted field being remembered by some subsystem or other, leading to this error being thrown on whenever cron runs:

SQLSTATE[42S02]: Base table or view not found:
1146 Table 'drupal8_neu_default.field_deleted_data_1c89727af8' doesn't exist:
SELECT DISTINCT t.entity_id AS entity_id
FROM {field_deleted_data_1c89727af8} t
WHERE  (bundle = :db_condition_placeholder_0)
LIMIT 50 OFFSET 0; Array
    [:db_condition_placeholder_0] => video
(line 1546 of /srv/www/neu.default.ch/builds/v1.0.0-alpha.7/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

I've spelunked all over the database, and I can't figure out where to expunge the reference to this long-dead table. It's not mentioned in config and the field_config table we knew from Drupal 7 is long gone. It's also not in the exported configuration.

Does anyone know how to fix this?


This is in the state/key_value table, with the keys field.field.deleted field.storage.deleted.

To find them, run this sql:

select * from key_value where name = "field.field.deleted" or name = "field.storage.deleted"

See \Drupal\field\FieldConfigStorage::loadByProperties() and \Drupal\field\FieldStorageConfigStorage::loadByProperties()

  • ... and then going ahead and deleting those is fair game, or poses what risk...? Seemed to be ok to nix the values from that table, but who knows(!) – NikLP Apr 25 '19 at 14:03

Execute this to remove deleted field(s), pending deletion:

drush php-eval 'field_purge_batch(1000);'
  • great, it's the right command for Drupal 7 too – Nicoschi Nov 4 '19 at 17:20
  • 1
    This quickly generates the error seen be the OP, but does not resolve it. – Mike Godin Jan 9 '20 at 14:17

The only way I could resolve this was to create the missing table, for example:

CREATE TABLE `field_deleted_data_XXX` (   
`bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '',
`deleted` tinyint(4) NOT NULL DEFAULT '0',
`entity_id` int(10) unsigned NOT NULL,
`revision_id` int(10) unsigned NOT NULL,
`langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '',
`delta` int(10) unsigned NOT NULL,
`content_translation_source_value` varchar(12) CHARACTER SET ascii NOT NULL,
PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`),
KEY `bundle` (`bundle`),
KEY `revision_id` (`revision_id`) );

Replacing XXX with the code that follows field_deleted_data_ in the error message. Then run:

drush php-eval 'field_purge_batch(1000);'

This may generate the error with a new code. I had to go through the process 3 times, but eventually it resolved the error.

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.