Problem/Motivation

I ran the update from 3.1.7 and 3.1.8 and the database update failed with this error
Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: The SQL storage cannot change the schema for an existing field (field_geo_area_info in taxonomy_term entity) with data. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateDedicatedTableSchema() (line 1750 of /var/www/drupal/next/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

Backtrace:

#0 /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php(1529): Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateDedicatedTableSchema()
#1 /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php(703): Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->performFieldSchemaOperation()
#2 /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1547): Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->onFieldStorageDefinitionUpdate()
#3 /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1592): Drupal\Core\Entity\Sql\SqlContentEntityStorage->Drupal\Core\Entity\Sql\{closure}()
#4 /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1546): Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException()
#5 /web/core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php(104): Drupal\Core\Entity\Sql\SqlContentEntityStorage->onFieldStorageDefinitionUpdate()
#6 /web/core/modules/field/src/Entity/FieldStorageConfig.php(420): Drupal\Core\Field\FieldStorageDefinitionListener->onFieldStorageDefinitionUpdate()
#7 /web/core/modules/field/src/Entity/FieldStorageConfig.php(340): Drupal\field\Entity\FieldStorageConfig->preSaveUpdated()
#8 /web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(528): Drupal\field\Entity\FieldStorageConfig->preSave()
#9 /web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(483): Drupal\Core\Entity\EntityStorageBase->doPreSave()
#10 /web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(239): Drupal\Core\Entity\EntityStorageBase->save()
#11 /web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Config\Entity\ConfigEntityStorage->save()
#12 /web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(617): Drupal\Core\Entity\EntityBase->save()
#13 /web/modules/contrib/custom_field/custom_field.install(183): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#14 /web/core/includes/update.inc(179): custom_field_update_8005()
#15 /web/core/includes/batch.inc(297): update_do_one()
#16 /web/core/includes/batch.inc(139): _batch_process()
#17 /web/core/includes/batch.inc(95): _batch_do()
#18 /web/core/modules/system/src/Controller/DbUpdateController.php(200): _batch_page()
#19 [internal function]: Drupal\system\Controller\DbUpdateController->handle()
#20 /web/core/lib/Drupal/Core/Update/UpdateKernel.php(115): call_user_func_array()
#21 /web/core/lib/Drupal/Core/Update/UpdateKernel.php(76): Drupal\Core\Update\UpdateKernel->handleRaw()
#22 /web/update.php(27): Drupal\Core\Update\UpdateKernel->handle()
#23 {main}

Data model changes

What should I do? Some manual SQL operation?
thanks

Giuse

Comments

giuse69 created an issue. See original summary.

apmsooner’s picture

Status: Active » Postponed (maintainer needs more info)

Hi, i'm not really sure how this failed you. I just tried the update on another installation with 3.1.7, added a bunch of data and then installed 3.1.8 and the update ran just fine. Maybe you can export the config for the field storage that is giving you problems and paste here and perhaps I can take a look. I'm not really sure why it thinks its changing schema in the db, the update is only changing settings. If anyone else has similar issues then maybe we can figure out a way to isolate it but whatever your storage config looks like may give us some clues. You can go to: /admin/config/development/configuration/single/export to get that.

giuse69’s picture

As an additional info, the update failed on custom_field module Update #8005, that I see in the code actually tries to change the schema.
Does this help?

apmsooner’s picture

in that update in the .install file, you can try adding this extra line right before the save action. If that works, just verify no data loss. I think its just triggering a safety feature in storage settings to prevent data loss although I still havn't been able to reproduce the issue. It could be helpful again if you could share the storage config for that field.

// Update the settings.
$field_storage_config->setSetting('columns', $columns);
$field_storage_config->setSetting('column_changes_handled', TRUE);
$field_storage_config->save();

giuse69’s picture

Hi, I added the line and the update again failed with the same reason

custom_field module
Update #8005
Failed: Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: The SQL storage cannot change the schema for an existing field (field_geo_area_info in taxonomy_term entity) with data. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateDedicatedTableSchema() (line 1750 of /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

The configuration for that field is the following

uuid: 1d4286d3-e313-419d-a3c1-04e1303979d0
langcode: en
status: true
dependencies:
  module:
    - custom_field
    - taxonomy
id: taxonomy_term.field_geo_area_info
field_name: field_geo_area_info
entity_type: taxonomy_term
type: custom
settings:
  columns:
    type:
      name: type
      type: string
      max_length: '20'
      unsigned: 0
      precision: '10'
      scale: '2'
      size: normal
      datetime_type: datetime
    code:
      name: code
      type: string
      max_length: '10'
      unsigned: 0
      precision: '10'
      scale: '2'
      size: normal
      datetime_type: datetime
    flag:
      name: flag
      type: string
      max_length: '255'
      unsigned: 0
      precision: null
      scale: null
      size: null
      datetime_type: null
      target_type: null
      uri_scheme: null
module: custom_field
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false
apmsooner’s picture

Status: Postponed (maintainer needs more info) » Needs review

I was able to reproduce and fix. Please try the dev branch and verify if the update goes through now. Please confirm for me as I will roll out another release for others that may experience the same issue.

giuse69’s picture

hi, with the dev version I get no more errors.
thanks

Giuse

apmsooner’s picture

Status: Needs review » Fixed
apmsooner’s picture

Status: Fixed » Closed (fixed)