default_content_deploy
- Export and deploy content to other instances
- Optionally maintain it in git
- Takes care about relations and dependencies, even in links or text
- Handles different entity IDs on different instances
WARNING! Due to a critical bug in the HAL module, entity references get lost during import with 2.2.0
There's a pending patch for the HAL module to fix the issue:
#3517446: Cached relation IDs are broken
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.
There's also an integration in Search API that leverages Search API's capabilities to track content changes and filter them to configure different "continuous content export streams".
DCD is also suitable to synchronize content between different instances in production.
Join Our Drupal Slack Channel for support.
Requirements
This module does not depend on the Default Content module (default_content)!
If you want to export files you should install the optional requirement Better Normalizers (better_normalizers).
If you want to export Layout Builder settings per entity or translations you'll currently run into two core issues you should patch:
- https://www.drupal.org/project/drupal/issues/2942975#comment-14351664
- https://www.drupal.org/project/drupal/issues/2904423#comment-14351658
Installation
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.
$settings['default_content_deploy_content_directory'] = '../content';
// Absolute path.
$settings['default_content_deploy_content_directory'] = '/var/dcd/content';
Usage - Drush commands
Read detail information about drush commands in README.md.
- default-content-deploy:export (dcde) Exports a single entity or group of entities.
- default-content-deploy:export-with-references (dcder) Exports a single entity or group of entities with references.
- default-content-deploy:export-site (dcdes) Exports a whole site's content.
- default-content-deploy:import (dcdi) Import all the content defined in a content directory.
- default-content-deploy:uuid-info (dcd-uuid-info) Get current System Site, Admin and Anonymous UUIDs, Admin name.
- default-content-deploy:entity-list (dcd-entity-list) List current content entity types.
How the content is imported
drush dcdi
- Imported entity is determined by UUID (it can be either new or already existing).
- ID of an entity is not preserved unless the
--preserve-idsoption is used (and you know what you're doing), so it can change its ID to avoid conflicts. - References by entity ID will be corrected during import based on UUIDs
- Existing entity is updated only if imported entity is newer (by timestamp of the last entity change across all translations).
- Imported entity with the same or older time than the current existing entity 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 entity 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
Originally written by @martin_klima and @hnilickajakub with kind support of @hideaway.
Maintained by @miroslav-lee @mkalkbrenner.