As part of #1239370: Module updates of new modules in core are not executed and #1018602: Move entity system to a module, we added a hook_schema_0(), with docs coming in #1929816: Remove all references to/implementations of hook_schema_0().

So now, when module_enable() is called within a hook_update_N(), the enabled module is installed with hook_schema_0() instead of hook_schema(), and then all of its update functions are executed, allowing the order of the newly enabled module's update functions to be interleaved as needed with the enabling module's update functions via hook_update_dependencies().

However, this means we need every module that has a schema to also have a hook_schema_0() (unless the module has an update function that creates its initial schema). If the module doesn't have a hook_schema_0(), then if it's enabled during another module's update function, it will fail to install correctly. Even if a core module isn't enabled by another core module's update function, it might get enabled by a contrib module's update function, so implementing hook_schema_0() seems necessary in order to allow for that.

CommentFileSizeAuthor
#1 upgrade-path-hook_schema_0.patch7.33 KBeffulgentsia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

effulgentsia’s picture

Here's a start that just does the modules that don't have any update functions that update the schema. We still need to add the following to the patch:
- aggregator
- comment
- dblog
- file
- locale
- node
- search
- shortcut
- statistics
- system
- taxonomy
- tracker
- user

But those will take a little time to reverse engineer (i.e., reverse the changes done in update function in order to reconstruct the 0 state), and in the meantime, I'd like to get reviews on whether this is the correct approach.

effulgentsia’s picture

Issue tags: +D8 upgrade path
Dave Reid’s picture

Seems like changing all the hook_schema() functions to call hook_schema_0() seems like it will be much more to do than leaving hook_schema() alone and calling it from hook_schema_0(). Feel like hook_schema_0() shouldn't do anything but that except in cases where it needs to be different from hook_schema().

Status: Needs review » Needs work

The last submitted patch, upgrade-path-hook_schema_0.patch, failed testing.

catch’s picture

See https://drupal.org/node/1929816#comment-7809645.

I think what we may need to do instead is add schema as an argument to update_module_enable() - then the module with the update can copy and paste the current state of whichever module's schema + schema version and that would be used instead of hook_schema(). hook_schema_SCHEMA_VERSION() is then a courtesy rather than an assumption in the module install system.

catch’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)