Problem
When exporting a full export there should be an option to export all of the configuration without UUIDs, so that I can—if I want to—import my config into a site that was not cloned from the site I am exporting from, but shares the same codebase. This is already a common use case for me and will be, I think, at least as common as importing from a clone.
Proposed resolution
Either
- Add a checkbox to the export form "include UUIDs in exported configuration" [description] "Configuration going to a clone of this site should include UUIDs, if configuration is being moved to another site, UUIDs will conflict and should not be included. Configuration will then overwrite configuration of the same name."
- Or the “import” tab could have the (unchecked) option “Strip UUIDs from imported config" [description] "If configuration originates from a different site (not a clone of this site) UUIDs must be stripped before import, Imported configuration will then overwrite configuration of the same name."
- Or (ideally) when the sync process detects that the config is from a different site, present the user with a dialog that says "This configuration appears to be from a different site (not a clone of this site), Import anyway? y/n Imported configuration will overwrite existing site configuration of the same name.
Related issues
#2628144: Ensure that ConfigImport is taking place against the same code base
Comments
Comment #2
tkoleary commentedComment #3
tkoleary commentedComment #4
tkoleary commentedAdded to config management usability meta #2642404: [meta] Usability improvements to configuration management post 8.0
Comment #5
dawehnerIMHO the actual solution is to point people to https://www.drupal.org/project/config_installer
There is a reason why this feature is not allowed. Feel free to read more on https://www.drupal.org/node/2133325
Comment #6
tkoleary commentedI fully agree with Moshe's comment (#34) in that issue, (paraphrasing) to allow the user to override and import config from a different site if they want.
The fact of the matter is that people who are aware of the potential risks are already doing this by manually removing the UUIDs but that's a painful process (even if I write a script to grep and auto-remove them) and there are plenty of other places in core where we provide a "do this at your own risk" type of warning.
Comment #7
tkoleary commented@dawhener
https://www.drupal.org/project/config_installer is only useful if I want to install a new site, not port configuration to an existing site.
Comment #8
dawehnerWell, I think making it super hard for people to break their site is not a bad thing.
Comment #9
xjmComment #11
dgtlmoon commentedThere's kind of a similar thread over at github/drush https://github.com/drush-ops/drush/pull/1875
Comment #12
dawehnerWell, IMHO the thing is that drush is for advanced users, for which we are fine to break stuff, as they maybe have good reasons for certain actions.
Comment #19
mlncn commentedOur primary use case for this feature is for feature building.
The
config/syncdirectory is never used to import, but it can be used to check if the result of a `site install` is about what we expect (and to copy wanted files or changes we wanted to keep, and missed, from a saved version).The meaningless UUID changes in every file, however, make it impossible to find that information in all the noise.
Here is a workaround that presumes you are using Git for version control, exporting configuration and committing it, then running a site install, and re-exporting the configuration (but not yet committing it):
git diff -G '^[^u]*([^u][^i][^d][^:]).*'will show only files with non-uuid changes. If there's a change to a uuid other than the one for the configuration as a whole (that is, indented under some other part of the configuration), that will be shown.
Super unsure about the regex in this but it's not had a false negative or positive yet.
Here's what i have in my .bashrc to make this easier to use:
Took me forever to come up with this workaround; hope it helps others.
And yes i would still like the option in drush!
Comment #21
colanI'd recommend creating an issue in the Drush queue then. Please link to it from here. (I just checked, and it doesn't exist.)
Comment #23
mrpauldriver commentedDid this get anywhere with with Drush?
All my Drupal 8 sites (30+) are clones of the same code base and I expect this is a common scenario for many not working in the enterprise space.
Aside from Drush, surely it is time for a more flexible approach to configuration management.
What is happening with this?
Comment #27
colanHere's another workaround, which edits the files in place. Note the differences with folks not using GNU
sed. (This is the Linux version; see there for how to modify if you're using BSD, or still use Apple products for some reason.)Comment #28
bircherI do not think core should have this feature. See the discussion of why UUIDs for config were added in the first place: #2133325: Create a site UUID on install and only allow config sync between sites with the same UUID
That said, of course people wanting this have a valid use case. All I am saying is that core shouldn't deal with this. Especially since it is very easy to create a contrib module which strips out uuids on export and re-sets them on import to the one that exist already (or random ones if they don't exist).
All one has to do is use the config transformation API added to Drupal 8.8
https://www.drupal.org/node/3066005
Config Split 2.x and Config Ignore 3.x are examples of modules that implement their functionality with this API.
I am also available on slack if someone wants help building such a module.
Comment #29
loopy1492 commentedIf you are maintaining a drupal profile and have a long and complex config/install folder, it sure would have been nice to have an option to export to that install folder without the uuids present. Having to strip those out is a huge pain.
Found this online:
```
sed -i.bak '/^uuid: /d' ./*
```