Rules for Config Management in Drupal 8 to avoid config quagmire, and developer consternation

Submitted bybarnettech onFri, 04/26/2019 - 11:02

Local development process:
Pull down latest code from the “development” branch into local with "git pull"
Run "drush updb" to update the database
Run “drush config-import” to import the database ("drush cim" is the shorthand command)
Make sure you select the 'sync' directory when asked
Make local changes
Run “drush config-export” (export to “sync” directory and remember that "drush cex" is the shorthand command)
Commit the config files in the “/config/sync” directory (ONLY COMMIT CHANGES YOU MAKE*)
Push the code to the upstream development branch using the terminal and the "git push" command

* when you do a drush config-export yml files will be created from your configuration. BUT drush config-export will export ALL config changes to YML files, MAKE SURE you only git add, and then git commit the YML files that are yours and are ready to be commited. AND MOST IMPORTANTLY, if you commit say some config for blocks, or views, or you added a new module and that module's config was exported – MAKE TRIPLE SURE that the view, module or block gets installed on stage and production where it will be config imported next. FOR the next developer will be doing a config-import and if said module, view or block DOES NOT EXIST then they shall be in config confusion trying to sort through config problems for lengthy periods of time. AVOID config quagmire.

Especially if working with vendor or contrib files, make sure you do composer install after you do any git pulls. And also, do a drush cim -y && drush updb -y && drush cr