Default Content Deploy - workflow example

A default content deploy solution for Drupal 9.

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.

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 toe export Layout Builder settings per entity or translations you'll currently run into two core issues you should patch:

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 with references.
  • default-content-deploy:export-site (dcdes) Exports a whole site content.
  • default-content-deploy:export-aliases (dcdea) Exports site url aliases.
  • default-content-deploy:import (dcdi) Import all the content defined in a content directory.
  • default-content-deploy:import-aliases (dcdia) Import site url aliases.
  • 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

  1. Imported entity is determined by UUID (it can be either new or already existing).
  2. ID of an entity is not preserved, so it can change its ID to avoid conflicts.
  3. References by entity ID will be corrected during import based on UUIDs
  4. Existing entity is updated only if imported entity is newer (by timestamp of the last entity change across all translations).
  5. Imported entity with the same or older time than the current existing entity is skipped.
  6. 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.

Supporting organizations: 
sponsoring
sponsor 2.0.x developemnt

Project information

Releases