0

I really want to like the configuration management system in Drupal. Over time, I've learned to tamp down my expectations in how it can be used to develop against a production config. On production, I've set up a display view_mode, which is complex undertaking using the admin interface for over 30 custom fields. Once I get one done, I want to "save as" into another display for this content type. In D7, in Display Suite, I had the option to clone an existing display, but cannot find that for the life of me.

So I create the new display for this content type so that it is instantiated in the db's config table. I then use drush cex to get them all, open up the source config file, copy the dependencies from the source config, paste only the analog dependencies in the newly generated display config file from the db. I take care to not overwrite the uuid values because they must map to the existing entities. Using either the Configuration Management module, or drush cim I get the SQL error that it will not overwrite/update the existing config.

Unexpected error during import with operation update for core.entity_view_display.node.doctor.internship: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'core.entity_view_display.node.doctor.internship_directory_photo' for key 'PRIMARY': UPDATE {config} SET ...

This ought to be doable, since all the dependencies are there, just wanting to save aggravation and time for all the variations I need to create.

More info on experiments. Say, my target config is "foo" and my file is foo.yml for this exercise. Comparing my source and target, I can see that a wholesale copy/past of the dependencies is too much. For one, there is an id key that must have the value of "foo" to match this new target config. There are others. Since there is a "foo" config in the config table, I deleted that row. Attempting drush cim the error is no longer a duplicate, but similar to this:

Unexpected error during import with operation create for foo; entity with foo already exists.

Hmm, I have not assigned a node to this display yet. Is it complaining about the config entity, or another, perhaps node, entity?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.