1

I have an existing content type on staging. On dev we've added a ton of new fields and display and form setting changes, etc.

It's not practical to go through the config files and find all of the many dozens if not hundreds of interconnected config files related to the content types, its fields and its settings.

So I heard Features is the way to go (even though I thought config sync in D8 was supposed to make Features not needed anymore).

So I've created my Feature. Keeping it simple I just checked the single content type. Saved my feature module and moved it to staging.

When I try to enable to the module I get a screen full of "unable to install" because the configuration already exists errors. Ugg.

So I read that I should remove the configurations. But this removes content and/or associated configurations like vocabularies.

Surely there must be a practical way to merge a content type from dev to staging?

6
  • What do you mean by merge? What's wrong with exporting the config, pushing it and importing the config on stage then?
    – leymannx
    Commented Apr 28, 2021 at 16:22
  • That's what I thought would work but it's not. By 'merge' I mean update an existing content type. The type exists already on staging with content in it. On dev we've added new fields and displays. But when using Features to import the content we get tons of 'config already exists' errors. Commented Apr 28, 2021 at 16:37
  • 2
    Okay, so first: Get the database from live to stage, dev and local. Now export config on local first to get a clean working state. This will be the current config from live. Deploy it. Now start to add fields and settings as you wish on your local page and when you are done, export config, deploy to all other environments.
    – leymannx
    Commented Apr 28, 2021 at 16:45
  • Yes, this is CMI and the practical way the OP is looking for. Features is something different. See drupal.stackexchange.com/questions/230270/…
    – 4uk4
    Commented Apr 28, 2021 at 20:14
  • @quantumized updated the answer for your use case. Commented Apr 29, 2021 at 4:45

1 Answer 1

2

To fix the issue include config in optional directory instead of install directory in your features module. It will then only install the config which are not present in the new site. Which will solve your issue.

When I try to enable to the module I get a screen full of "unable to install" because the configuration already exists errors.

Ok, I misread your question. To update existing config as well you need to do partial cim.

Copy the feature configs into a different directory named feature-config-sync (can be anything other than standard folder names) in default site config directory. And execute the below command. It will import new config and update existing configs if needed. Limitation is it wont delete any configs.

drush cim --partial --source=../path/to/config/feature-config-sync

IIRC you can even map the module install/optional config directory as source during partial import.

Once your import is done you can delete the feature-config-sync directory.

5
  • 1
    This will just skip processing any config that already exists, it won't update the existing config to the new config.
    – sonfd
    Commented Apr 28, 2021 at 16:56
  • Right. I just found that out. If I rename install to optional then the module installs but the content type is not updated at all. Commented Apr 28, 2021 at 17:32
  • I thought renaming install to optional would work as the Feature now enables but when I checked the content type it does not get updated at all. Commented Apr 28, 2021 at 17:43
  • @quantumized has the updated solution worked? Commented May 2, 2021 at 16:38
  • I finally got it to work but I'm not exactly sure how. After many attempts of retrying the Features module finally installed and merged the changes to the content type. Commented May 3, 2021 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.