Default Content Deploy
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
A default content deploy solution for Drupal 8.
Introduction
This module (DCD) provides content deployment and allows development and building sites without the need to transfer database between the sites. The development team can export and deploy all content via Git and content can be deployed to the staging servers automatically during common deploy processes. Module provides useful drush commands for export/import content. Import function can also be ran from administration interface.
Requirements
- Default Content for Drupal 8 (default_content) - https://www.drupal.org/project/default_content
- optionally File entity (file_entity) or Better Normalizers (better_normalizers) - if you need to deploy files, f.e. images, attachments
https://www.drupal.org/project/file_entity, https://github.com/drupal-media/file_entity,
https://www.drupal.org/project/better_normalizers
Install
Download and enable module.
Configuration
Set DCD content directory in settings.php. We recommend to place directory outside of the document root. If no configuration is found, directory is created automatically at 'public://content_' . $hash_salt;
Example
// relative path
$config['content_directory'] = '../content';
// absolute path
$config['content_directory'] = '/var/dcd/content';
Usage - Drush commands
Read detail information about drush commands in README.md.
- drush default-content-deploy-export, drush dcde
- drush default-content-deploy-export-with-references, drush dcder
- drush default-content-deploy-export-site, drush dcdes
- drush default-content-deploy-export-aliases, drush dcdea
- drush default-content-deploy-import-aliases, drush dcdia
- drush default-content-deploy-import, drush dcdi
How the content is imported
drush dcdi
- Imported entity is determined by UUID (it can be either new or already existing).
- ID of entity is preserved, so entity can not change its ID.
- Non-existing entity (the new one) is created with exported ID.
- Existing entity is updated only if imported entity is newer (by timestamp of the last entity change).
- Imported entity with the same or older time than the current existing entity is skipped.
- If a file entity does not have an existing file, the file will be created. The file will be recreated even if there is a existing file entity but its file has been deleted.
- If the new entity ID is already occupied by some existing entity, it is skipped.
- This behavior can be changed by parameter --force-update
drush dcdi --force-update
- Existing entity is overwritten by the imported entity (the old entity is deleted and a new entity with the same ID is created from imported JSON file).
- There is an exception for the user-type entity that only updates the UUID and the username, because overwriting a user entity would result in creating a blocked user without password and email (the user entity export JSON file doesn't contain such information).
drush dcdi --verbose
Print detailed information about importing entities.
If you can not use Drush for import, go to page /admin/config/development/dcd-import.
Team workflow - how to synchronize configuration and content between sites
Please, read the README.md for detailed information.
Credits
Written by @martin_klima and @hnilickajakub with kind support of @hideaway.
