Drupal Camp Bangalore Getting into Drupal 8 Migration | making happiness possible axelerant.com
About Me Mohit Aghera Drupal Developer @Axelerant Drupal : mohit_aghera Twitter: mohit_rocks | making happiness possible axelerant.com
D8 Migrate in core • The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten. • Moved into Drupal 8 core. • Their scope has been expanded. | making happiness possible axelerant.com
D8 Migrate Background • core/modules/migrate • core/modules/migrate_drupal | making happiness possible axelerant.com
D8 Migrate in Core • Most of the D6->D8 migration work is done - some bugs remain. • D7->D8 migration work is in progres !! • Migration UI doesn’t comes in D8 Core {Separate module} • Advanced feature like rollback, reset are not yet in core. | making happiness possible axelerant.com
Migrations are Plugins !! • Yaayy… D8 Migration API is extensible using plugin. • It leverages standard D8 Plugins. • Now we are able to provide migration support to any content and configuration data of any contrib or custom module. | making happiness possible axelerant.com
Type of Migrations !! • Content migration • Node migration • User migration • Config migrations • Variable migrations • Field migrations • Entity type migrations | making happiness possible axelerant.com
The anatomy of migration • Migrate source • Migrate process • Migrate destination | making happiness possible axelerant.com
Content of migration_template file • File “migrate.migration. migrate_example_user_role. yml” • id : same as last part of file name • source : configure source data; usually source plugin • destination: destination entity • process : list of processors plugins applied to destination field. | making happiness possible axelerant.com
Migrate Source • Migration configuration entity contains source key • Value is an associative array • {name} => {Configuration of plugin} | making happiness possible axelerant.com
Migrate Process process: uid: • The Shorthands plugin: migration • Simple copying id: users • Created by one plugin source: author | making happiness possible axelerant.com
Migrate Process process: format: - • The full pipeline plugin: machine_name • Source value may be source: name passed to multiple - plugin: dedupe_entity plugins. entity_type: filter_format field: format | making happiness possible axelerant.com
Migrate Process • Nested values • For: • $destination['display_settings']['label']['format'] • $source['display_settings']['label']['format'] • display_settings/label/format | making happiness possible axelerant.com
Process Plugin : get process: bar: plugin: get source: foo • Typically, “get” plugin is start process: of each pipeline bar: foo • Simply copies “Source” value to “Destination” process: foo: plugin: machine_name source: baz bar: plugin: get source: “@foo" | making happiness possible axelerant.com
Process plugin: callback process: destination_field: - • Allows source values to be plugin: callback passed to a callable callable: • Prefered to use only one - '\Drupal\Component\Utility\Unicode' - strtolower argument to avoid very source: source_field complex YAML | making happiness possible axelerant.com
Process Plugin: Concat process: new_text_field: plugin: concat source: - foo - bar • Allows to concatenate source values for relevant D8 destination values process: new_text_field: plugin: concat source: - foo - bar delimiter: / | making happiness possible axelerant.com
Process Plugin: dedupe_entity process: format: - plugin: machine_name • dedupe_entity is used to source: name prevent duplication. - plugin: dedupe_entity • Usually used with entity types entity_type: filter_format and fields. field: format | making happiness possible axelerant.com
Process Plugin: dedupebase process: new_text_field: • Avoids duplication at the plugin: dedupebase source: some_text_field destination postfix: _ • We can also specify a postfix start: 2 delimiter, a start position, and length: 6 a length | making happiness possible axelerant.com
Process Plugin : default_value process: uid: - • Provides ability to set fixed plugin: migration default value id: users • sets the pipeline to the default source: author - value if the pipeline has no plugin: default_value value (NULL, zero or empty default_value: 44 string) | making happiness possible axelerant.com
Process Plugin : extract process: new_text_field: plugin: extract source: some_text_field • Pulls data from potentially index: multi-level arrays in the source - und - 0 • Ex: Used for Drupal 7 fields - value | making happiness possible axelerant.com
Process plugin : flatten • Takes multi-dimensional arrays and flattens it. • Source : array(array(1, 2, array(3, 4)), array(5), 6) • Destination: array(1, 2, 3, 4, 5, 6). | making happiness possible axelerant.com
Process Plugin: Machine name process: bar: plugin: machine_name source: foo • Prepares source string like machine name Source: áéíK! Destination: aeik_ | making happiness possible axelerant.com
Process plugin: Migration process: uid: • Maintains relationship among plugin: migration source and destination content migration: users in map tables. source: - author | making happiness possible axelerant.com
Process plugin : skip_process_on_empty process: parent: - • Checks whether current plugin: skip_process_on_empty source: parent pipeline is empty. - • If so, skip processing. assign plugin: migration value to destination. migration: d6_taxonomy_term | making happiness possible axelerant.com
Process plugin: skip_row_if_not_set process: settings: • Checks if value isset. plugin: skip_row_if_not_set • If set, returns value otherwise index: contact source: data “MigrateSkipRowException” exception | making happiness possible axelerant.com
Process Plugin : skip_row_on_empty process: field_type_exists: - plugin: migration migration: d6_field source: - field_name • Entire row is skipped if value is - empty plugin: extract index: - 1 - plugin: skip_row_on_empty | making happiness possible axelerant.com
Process Plugin : Static Map process: bar: plugin: static_map source: foo • Allows looking up a value map: based on a map specified in from: to the configuration. this: that | making happiness possible axelerant.com
Static map real example process: id: plugin: static_map source: - module - delta map: filter: 0: filter_html_escape 1: filter_autop 2: filter_url 3: filter_htmlcorrector 4: filter_html_escape php: 0: php_code | making happiness possible axelerant.com
Migrate Destination • Destination has mandatory destination: plugin: config plugin key like entity: config_name: book.settings entity_type • URL aliases are also exportable | making happiness possible axelerant.com
Migrate destination • Migrate destination: component_entity_display • Migrate destination: component_entity_form_display • Migrate destination: entity:user | making happiness possible axelerant.com
Migrate Example • We will migrate users and roles from non-drupal database to drupal 8 | making happiness possible axelerant.com
Questions ?? | making happiness possible axelerant.com
Thank you !! | making happiness possible axelerant.com
Recommend
More recommend