My custom module creates a content type which has fields. I want to export config so that other developers/production can use it. I run

drush config-export --destination=/tmp/myconfig

from /tmp/myconfig I take the following files:

field.field.node.CONTENT_TYPE.FIELD_NAME.yml   #field instance
field.storage.node.FIELD_NAME.yml   #field storage

and copy these files to modules/custom/mymodule/config/optional

In the destination machine I run

drush config-import  --partial --source=modules/custom/mymodule/config/optional

The field instance gets imported (I can see it on the content type) but the storage does not, and no table is being created in the database.

Am I doing anything wrong? Uninstalling and re-installing the module doesn't help.

  • what happens when you manually try to import them via admin/config/development/configuration/single/import - could drush cmi straight out ignore "optional" configs ?? – taggartJ May 16 '18 at 23:25

At Drush Commands something similar is mentioned in the comment of Sebastian Contreras:

--partial and --source "custom directory" are not working at all after upgrading Drupal 8.3 to Drupal 8.4 and Drush8 to Drush9. It does not detect the source with --source and it does not detect the --partial causing lots of removals where they should not happen.

However, did you already try the Configuration Split module? This module allows you to create different sets of configuration stored in multiple directories, and merge them back together when needed/indicated.

I'm using the Configuration Split module mostly to exclude configuration that is only needed in my development environment and not in production (modules such as Devel and Stage File Proxy). If I understand your use case correctly, this module should be able to perform the thing you want.

| improve this answer | |
  • Thanks @Watergate - before I try CS (Configuration Split) I'd like to make sure it's appropriate. As far as I understood CS works with blacklists while what I need is to white list my custom module. – roi May 17 '18 at 12:41
  • @roi In the support queue of CS is some discussion on the used terms such as 'blacklist' (as people interpret them differently). But what the module does is that it splits your configuration to multiple directories (besides sync). So in your case you can define a split for 'optional' and when you set e.g. $config['config_split.config_split.optioal']['status'] = TRUE; in your settings(.local).php that configuration is added under the hood when importing. – Watergate May 17 '18 at 13:32
  • @roi Besides 'blacklisting' there is also the option for conditional split, this is useful when you want/need configuration to be present in sync (i.e., default/initial configuration) and want to overrule for certain situations. – Watergate May 17 '18 at 13:34

Your Answer

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

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