Constant values

Last updated on
9 May 2023

This documentation needs work. See "Help improve this page" in the sidebar.

Sometimes you need a constant value. Perhaps it's for the concatenation plugin or simply some value that is always fixed. In this case, first you need to define a constant in the source and then use it as any other in your process. The following example sets the value of the id destination property to node_search:

source:
  constants:
    id: node_search
process:
  id: constants/id

Note that the constants key is not special. If the source contains a constants property, use another name, for example defaults. In other words, the code example below is equivalent to the previous one:

source:
  defaults:
    id: node_search
process:
  id: defaults/id

This works because the definition of the source provides the default values for every row retrieved from the source (without deep merging).

Please note that using the default_value process plugin is an alternative and simpler way to define constant values in the destination.

Contrib module migrations

While custom migrations need to specify their config dependencies explicitly, the migrate_drupal module automates part of this by treating the value of constants/entity_type as a Drupal 8 entity type and adding a dependency on the module providing said entity type. This is strictly migrate_drupal specific.

Help improve this page

Page status: Needs work

You can: