EntityStorageException after field delete and reimport

Created on 24 November 2015, almost 9 years ago
Updated 11 December 2023, 12 months ago

Error

The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. Cannot rename node__field_r to field_deleted_data_b9d6309b74: table field_deleted_data_b9d6309b74 already exists. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1457 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

How to reproduce

  1. Export config
  2. Delete a field from a node in the UI
  3. "Undelete" field with drush config-import
  4. Delete the same field again in the UI.

One will get a similar error message like above.

🐛 Bug report
Status

Closed: outdated

Version

9.4

Component
Field 

Last updated about 12 hours ago

Created by

🇭🇺Hungary EdgarPE

Live updates comments and jobs are added and updated live.
  • Triaged core major

    There is consensus among core maintainers that this is a major issue. Only core committers should add this tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada jdhildeb

    I hit this error in my development process working on a dev copy of a site.
    It can be reproduced as follows:

    1. Remove a field from your database (Drupal will rename the database table).
    2. Export configuration.
    3. Load a database snapshot from production (for example to debug a separate issue).
    4. Import configuration.
    5. Error occurs. In my case: Unexpected error during import with operation delete for field.storage.node.field_need_date_change: Exception thrown while performing a schema update. Cannot rename 'node__field_need_date_change' to 'field_deleted_data_f21a3876bc';: table 'field_deleted_data_f21a3876bc'; already exists.

    The cause in my case was that I did not drop my existing database when loading the snapshot, I just simply loaded a mysqldump. This overwrites existing tables, but does not delete tables from your database which are not present in the new snapshot. So the previous copy of field_deleted_data_f21a3876bc from step 1 was still there in my local database, remained when loading the snapshot, and caused the error when I tried to import my configuration.

    The workaround is to do drop database, create database before loading your snapshot, to clear out any unwanted tables like this.

Production build 0.71.5 2024