[Drupal 8] use sed (on OSX) to strip the uuid line from exported config files being used for module default configuration; i.e. [module_name]/config/optional|install
NOTE: this can also by bypassed in the export by using Drupal Cnnsole and including the --remove-uuid
flag. Also using the --remove-config-hash
flag can help prevent additional headaches.
Ex:
drupal config:export --directory=”[full-path-to-location]” --tar --remove-uuid --remove-config-hash
The UUID should never be included when using when using these exported config yaml files as the default configuration pagaged with a custom module. This is suppoedly not to be a thing in the exported yaml files at some point, but until then stripping the uuid line out is a manual process which can be a pain as there can be a lot of files.
To automate this, run the following sed command in the directory containing the yaml files:
sed -i.bak '/^uuid: /d' ./*
The i.bak
arg will create a backup of the affected file. When satistifed with the results, you can safely get rid of the .bak files:
rm *.bak
References:
Thanks for taking the time to look into this after all those years.
I have found many contradictory information regarding this. As far as I understand it, the UUID is used to locate and update the config when there is an update to the YAML config file in the module. Without the UUID, Drupal has no way to determine if it's a new YAML or an updated one and it would not know how to update the resource on the website. Removing the UUID would work as long as the YAML file never changes in the module, which is obviously not a good assumption to take.
Here I'm assuming Drupal would actually update the entity on the website when the YAML file is changed. I haven't tested this yet. I'm still new to Drupal 8+. I'm still discovering the ins and outs. It can be very difficult and frustrating to know the best practices in cases like this one.
If you do not remove the UUID, it's true that every website which install your module will have the same UUID, but that's a small price to pay for maintainability.
I will experiment with this today and edit this post with my findings...
[EDIT] It doesn't seems like Drupal wants to update resources created using YAML files. From what I have read, I would need to create an update function in the
.install
file, list the updates, loop through the list and execute them in my update function. I have changed my YAML file but thegetChangeList
method returns nothing.