There are two kinds of updates we need when updating between 8.x versions:
1) Entity updates (added field, removed field, etc)
Pretty similar to D7, plenty of examples in core
2) Config updates
Nobody's doing it yet in contrib yet.
D8 CMI makes the assumption that the user owns the config, not the module, so after the module is installed, that's it, no updates.
This is the complete opposite of the way config worked in D7, so we need to be careful.
An update needs to:
a) Install new config
b) Delete removed config (rare)
c) Update changed config
a) and b) are easy to do manually. c) is the tricky one.
Ideally we'd be able to specify the semantics of config ownership: "leave this config alone" VS "keep refreshing this config" VS "refresh this config only until the user customizes it". I don't see many use cases for always refreshing the config, guessing "refresh until the user customizes it" would be the default.
The config_update module has an API that we might be able to use.
Related core issue: #2656370: Create a method to discover if configuration matches the shipped configuration.
Comments
Comment #2
bojanz commentedNote that the various D8 config update modules insist on having a UI that pushes the responsibility/complexity of reviewing updates to the end-user.
The average end-user will run away screaming.
Instead, we as module maintainers need to make the decision ourselves, in our update hooks. Having an API to use in update hooks currently feels better than trying to automate it, but let's see how to code turns out.
We'll also want to document common cases such as:
- Updated view
- Added configurable field
etc
Comment #3
bojanz commentedmglaman has made good progress on the config update helper class.
https://github.com/drupalcommerce/commerce/pull/347
Comment #4
bojanz commentedAfter many iterations we've created the ConfigUpdater service that covers the needed functionality:
https://github.com/drupalcommerce/commerce/commit/af4e4bb3507cc1119e92ea...
Verbose usage example:
Matt will do a blog post soon.
Comment #5
agoradesign commentedThank you very much for this great work! Looks very very interesting :-)
Have you thought of moving the ConfigUpdated into a seperate project? Looks useful for any kind of project, not only Commerce ones
Comment #6
bojanz commented@agoradesign
I wouldn't want to duplicate the config_update module (which has already settled on its own API).
In my opinion this code needs to live in core.
mglaman is adding the isModified() helper to #2656370: Create a method to discover if configuration matches the shipped configuration and I've opened #2684081: Modules need a way to keep their configuration up to date for the entire thing.
Comment #7
agoradesign commentedYou're absolutely right... I've commented on your core issue, trying to clarify that the existence of such helper functions only have advantages, as you can never fully prevent module authors from doing stupid things...