Exporting Config - envris/White-Label-Help-Wiki GitHub Wiki
The process for making configuration changes is defined so that configuration changes can be exported and imported between sites and changes are not lost after each deployment.
The GovCMS site uses database settings to record changes to all configuration values. These settings can be exported to files and committed to the repository for the website.
The website is built from a combination of configuration (which is stored in the database) and code (which are stored as files on disk).
Whenever a change is made to the repository, a deployment process is used to automatically:
- Apply the code changes
- Make the database settings the same as the settings stored in code
- Run any upgrade steps included in the code changes
- Rebuild and caches that could be affected
If there are differences between the settings stored in the code, and settings stored in the database for the website, those database changes will be removed when a deployment occurs. There are 2 ways to prevent the database changes from being lost:
- Add the configuration to the "config ignore" setting
- Export the configuration and commit the changes to the code repository
The "Config ignore" settings are a list of configuration values that will not have any changes applied to them by the deployment process. Because they are stored as settings themselves, any changes to the config ignore settings have to be made by changes in the code and committed to the repository. The file containing these settings is "config/default/config_ignore.settings.yml".
ignored_config_entities: - 'webform.webform.*' - 'webform.webform_options.*' _core: default_config_hash: [unique hash]
Some standard settings are usually listed to be ignored in this settings file, e.g. "All webforms". This allows users with the required permissions to create and use webforms on the site without losing their changes on each deployment.
The configuration files are stored in repository in the folder: /config/default/
They are stored in a set of YAML files which match the structure of the database for the website. Every setting will have a corresponding entry in a YAML file in this folder.
Making any changes to the code will require a local development installation of the website. Installation Instructions.
Once you have a development environment available, you can make changes to the code and commit the result to the repository.
The process is:
- Update the code to the latest version of the website using git: "
git checkout -b <branch name>; git fetch origin master; git reset --hard FETCH_HEAD" - Update the database to the latest version. There is a command available for this which is: "
ahoy refresh-db" - Make changes directly in the website by logging in as a user with the required permissions.
- Use the command "
ahoy drush cex" to export the configuration directly to the configuration files under "config/default". - Commit those changes to the repository: "
git add config/; git commit" - Review those changes and make sure they only include the intended settings: "
git show" - Push those change back to the repository: "
git push origin <branch name>" - You will now be able to create a merge request to merge the changes from the feature branch to the deployment branch (master)
- When the change is merged to the master branch, a deployment will be triggered to update the website with the changes.
If you have configuration changes in your database and you want the database to match the settings stored in the config directory, you can run "ahoy cim" which will import all settings from the config files in the code to your current database. This action is performed automatically on the website every time a change is made to the code.