I'm building a custom module in Drupal 8. It includes some YAML config files.
As I develop I need to change and add to the config, e.g. to add another field onto my custom entity.
At present the only way I've found to get Drupal to notice the changes is to uninstall the module and re-install it.
Is there a way to get Drupal to check that the config files provided by modules is the same as the active config, and if not, update the active config? How are module updates handled? In D7 hook_update_N
would be used to add fields using PHP, but it looks like this should be handled by the CM in D8?
Things I've tried after updating the yml files in the module:
drush cr
, config sync.manually copying all the updated config files into
sites/default/files/config_XXX/staging/
- but this gives this error "The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.".manually importing the files one by one using the config manager. This works, but obviously there must be a more automatic way.
[EDIT] manually use the config_update module to inspect changes and 'revert' to the module's config. Again, this is manual.
EDIT: From Managing configuration - do's and don'ts
DON'TS
Try to change the active configuration on your site by changing files in a module's config/install directory. This will NOT work because Drupal will only read from that directory when the module is installed.
...but changes there are going to happen, unless modules are bound to whatever config they needed in their first ever release, and may never ever update or add config.
Thanks in advance.
hook_update_N
I'd assume, but I'm not sure whathook_update_N
. Excellent article on Drupal 8 for small sites (and part 2). In D8 "sites own their configuration, not modules".