Problem/Motivation

While trying to add a UUID to an entity type that doesn't already have one, I discovered that the field is added to the wrong table when using \Drupal::entityDefinitionUpdateManager()->installFieldStorageDefinition() in an update hook - it is added to the data table instead of the base table. If the entity type is created from scratch, the field is correctly set up in the base table.

This appears to be because SqlContentEntityStorageSchema uses the active entity type definition, which doesn't have a UUID key (because the entity wasn't initially installed with one), and so the field is selected for the data table instead of the base table in DefaultTableMapping::create().

This is also documented on Stack Overflow at https://drupal.stackexchange.com/questions/302719/how-can-i-add-a-proper... but I couldn't find an issue in the core queue for it.

Steps to reproduce

Install an entity type without a UUID.
Add a UUID base field and key to the entity type class.
Try to install the field schema with \Drupal::entityDefinitionUpdateManager()->installFieldStorageDefinition().

Proposed resolution

?

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

longwave created an issue.