Drupal 8 Field Type Schema column add / change / delete HOOK_update

As heavily discucced in this years old issue: [#937442] there isn't a good solution or helper in Drupal core currently to change the schema of a custom field.

Modules like

  • field_collection
  • dynamic_entity_reference (#51)
  • address
  • viewsreference
  • ...

are having the same problem and wrote their own hook_update implementations as workaround.

Until the issue is solved I wrote two first helper functions to use in a modules .install file to change the field type schema columns:
https://gist.github.com/JPustkuchen/ce53d40303a51ca5f17ce7f48c363b9b

Please feel free to fork or extend my implementations.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.

More information about formatting options