Follow-up from #2333113: Add an EntityDefinitionUpdateManager so that entity handlers can respond (e.g., by updating db schema) to code updates in a controlled way (e.g., from update.php). In that issue we introduced a new kind of update. In addition to the familiar updates that are defined by hook_update_N() functions, we added EntityDefinitionUpdateManager, which checks if the current codebase is defining and using modified entity type and field storage definitions that the entity handlers need to be notified of. This is done as part of update.php, because an example kind of handler is SqlContentEntityStorageSchema, which needs to update the database schema to work for the new definitions. In Drupal 7, these kinds of entity table changes were done as update functions in the entity type's module: for example, node_update_7005(), but in Drupal 8, those tables are under the control of swappable handlers (e.g., one could use a NoSQL backend), and hooks like hook_entity_type_alter() and hook_entity_base_field_info_alter() make it so that there's no one clear module that should define the hook_update_N() entry point. So, instead, those updates are summarized and invoked by EntityDefinitionUpdateManager rather than as hook_update_N() functions.

Several issues emerge from this, however, that could use some UX improvement:

  1. Does it make sense to list these updates on the same step of update.php, as currently, or should we switch to a dedicated step in the UX flow? For example, see screenshots in #1498720-145: [meta] Make the entity storage system handle changes in the entity and field schema definitions that were proposed, but we backed away from in #2333113: Add an EntityDefinitionUpdateManager so that entity handlers can respond (e.g., by updating db schema) to code updates in a controlled way (e.g., from update.php) due to wanting more UX discussion about that.
  2. What should the labels say? They currently say things like "Create the Foo field", "Update the Foo field", "Delete the Foo field", or "Update the Bar entity type" (see screenshot in #2333113-65: Add an EntityDefinitionUpdateManager so that entity handlers can respond (e.g., by updating db schema) to code updates in a controlled way (e.g., from update.php)). However, that's not 100% accurate, because in some sense those creations/updates/deletions already happened regardless of running update.php: the codebase immediately uses the new definitions as soon as the code is deployed. What update.php is doing is just notifying the handlers of those creations/updates/deletions, so that they can react, by e.g., adjusting the database schema if necessary. Are there generic labels that can explain this, or should we add make it the responsibility of each handler to return specific text about what it will do?
  3. If there's existing data in the entity tables, and the schema change requires dropping and recreating the table, or moving the data to a different table, the update currently fails with a generic "The SQL storage cannot change the schema for an existing entity type with data." error message. How can we improve the UX of that? For example, should we mention that in the overview step and disable the "Apply pending updates" button, rather than only mentioning it after the user clicked that button?

Comments

Bojhan’s picture

Issue tags: +Usability, +Needs design

This issue really covers a bunch of different parts.

1. I'd like Plach his argumentation for this. Strategically we have never decided what should be in the status page. We decided foremost that updates just handles everything regarding database changes, now that we have some in flux we need to think about that. Drupalcon maybe?

2. Can we be more specific? If its possible, we should do that. Because it might be confusing when you see a label here that kinda mentions what you already did a few hours ago. Doing it here isn't like extra confirmation or so. Its even more confusing I guess when fields is still runnings its delete batch?

3. That is horrible, can we make a separate issue for this?

plach’s picture

3. That is horrible, can we make a separate issue for this?

Yeah, I already wanted to introduce validation during the entity schema review step so you wouldn't get that far before knowing your updates cannot be applied. No preference about same issue vs different one.

plach’s picture

Issue tags: +entity storage
askibinski’s picture

Regarding #3, is there a separate issue on this?

I'm chasing Drupal 8 development with a site with content and try to keep up with database updates. But I'm having a lot of entity type storage changes (see screenshot) which can't be completed (the site is multilingual). I would be able to manually make these changes in the database but I would have to know what they are.

plach’s picture

Well, the idea is that if you have data you'd use Migrate to perform schema changes. Not sure this issue can help you: it's just about preventing the user from running updates when we already know they won't complete.

plach’s picture

@askibinski:

Perhaps #2346013: Improve DX of manually applying entity/field storage definition updates may be more interesting for you.

plach’s picture

Status: Active » Closed (works as designed)