We recently migrated successfully in our drupal 8 instance from field collection module (latest alpha) to paragraphs. Now I am trying to remove the field collection module from our drupal instance, but it cant be removed as it is "used in the field field_collection_item.field_sprechzeiten_zeitraum" (see screenshot from uninstall view).

uninstalling field_collection is prevented

When I try to delete this field field_sprechzeiten_zeitraum, the following error message is displayed:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'druco_stage.field_collection_item__field_sprechzeiten_zeitraum' doesn't exist: SELECT 'entity_id' FROM {field_collection_item__field_sprechzeiten_zeitraum} WHERE 'bundle' = 'field_sprechzeiten'; Array ( ) in field_collection_field_config_predelete() (line 95 of modules/contrib/field_collection/field_collection.module).

It looks like somebody had tried to delete this earlier and something went wrong, as the database entry was deleted but not all the other references or the entry was not created in the first place.

As I am no drupal dev and just administrating this site, I am quite clueless, how to deal with it. I just want the field_collection module to be gone, has anyone an idea how to solve this problem?

  • 1
    I'm glad my answer gave you a push in the right direction! However, as @leymannx suggested in comments below, it's better to cut your "Edit:" section from the question above and paste it into an answer below, even though you have already accepted my answer. This will help people in the future who seek a solution to a similar problem. Please consider it! Thanks in advance. Aug 14 at 20:32

Do you have any old database backups? You could spin up a copy of the site in a local development environment and restore an old version of the database to see whether the missing tables can be recreated, allowing you to remove the field_collection module.

Generally, it is a bad idea to make such changes directly in the database (which is likely what someone did to create the problem in the first place) but you may be able to create an empty table with the same structure by analyzing the table in the old backup:

DESCRIBE field_collection_item__field_sprechzeiten_zeitraum;

Armed with this information, you may be able to create a matching table structure in the production database -- again, working in a local copy rather than on the production server.

If no suitable backups are available, you may be able to use the field_collection module to add the field_collection_item__field_sprechzeiten_zeitraum to the field_sprechzeiten bundle. (You won't be able to recreate the field contents this way, but you are just trying to delete it anyway.)

Once the missing table exists (even if it is empty) you may be able to remove the field without error and uninstall the module. Good luck.


I solved the problem by creating a new table as suggested by hotwebmatter. It was quite easy because i could use the structure of other field collection fields and just rename the value field. The structure looked like this:

field_collection_item__field_sprechzeiten_zeitraum: table
+ columns
    bundle: varchar(128)
    deleted: tinyint(4) NN
    entity_id: int(10) NN
    revision_id: int(10)
    langcode: varchar(32) NN
    delta: int(10) NN
    field_sprechzeiten_zeitraum_value: varchar(255)
+ indices
    bundle: index (bundle) type btree
    revision_id: index (revision_id) type btree
+ keys
    #1: PK (entity_id, deleted, langcode, delta)

After creating this I purged the field collection entities (there was a link in the uninstall section) and removed the remaining fields in my content types. The checkbox to uninstall the module was still disabled, so I deleted every table in the database containing field_deleted_data and field_deleted_revision. This didn't help, so I searched in the config table for the line with the name core.extension. Here I deserialized the data, removed the part with field collection, and serialized it again.

In between I always run the cron job and purged the caches. The checkbox to uninstall was still disabled, and by chance I saw that field collection checkbox in the module install section was not checked anymore. I checked it and tried to install it. It started and I was then forwarded to the module install section. the field collection was still unchecked and when I examined the uninstall tab it was finally gone.

This was gruelling, but with a happy end.

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.