Drupal Camp Bangalore Getting into Drupal 8 Migration | making - - PowerPoint PPT Presentation

drupal camp bangalore
SMART_READER_LITE
LIVE PREVIEW

Drupal Camp Bangalore Getting into Drupal 8 Migration | making - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

| making happiness possible axelerant.com

Drupal Camp Bangalore

Getting into Drupal 8 Migration

slide-2
SLIDE 2

| making happiness possible axelerant.com

Mohit Aghera Drupal Developer @Axelerant Drupal : mohit_aghera Twitter: mohit_rocks

About Me

slide-3
SLIDE 3

| 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.
slide-4
SLIDE 4

| making happiness possible axelerant.com

D8 Migrate Background

  • core/modules/migrate
  • core/modules/migrate_drupal
slide-5
SLIDE 5

| 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.

slide-6
SLIDE 6

| 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.

slide-7
SLIDE 7

| making happiness possible axelerant.com

Type of Migrations !!

  • Content migration
  • Node migration
  • User migration
  • Config migrations
  • Variable migrations
  • Field migrations
  • Entity type migrations
slide-8
SLIDE 8

| making happiness possible axelerant.com

The anatomy of migration

  • Migrate source
  • Migrate process
  • Migrate destination
slide-9
SLIDE 9

| 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.

slide-10
SLIDE 10
slide-11
SLIDE 11

| making happiness possible axelerant.com

Migrate Source

  • Migration configuration entity contains source key
  • Value is an associative array
  • {name} => {Configuration of plugin}
slide-12
SLIDE 12

| making happiness possible axelerant.com

Migrate Process

  • The Shorthands
  • Simple copying
  • Created by one plugin

process: uid: plugin: migration id: users source: author

slide-13
SLIDE 13

| making happiness possible axelerant.com

Migrate Process

  • The full pipeline
  • Source value may be

passed to multiple plugins.

process: format:

  • plugin: machine_name

source: name

  • plugin: dedupe_entity

entity_type: filter_format field: format

slide-14
SLIDE 14

| making happiness possible axelerant.com

Migrate Process

  • Nested values
  • For:
  • $destination['display_settings']['label']['format']
  • $source['display_settings']['label']['format']
  • display_settings/label/format
slide-15
SLIDE 15

| making happiness possible axelerant.com

Process Plugin : get

  • Typically, “get” plugin is start
  • f each pipeline
  • Simply copies “Source” value

to “Destination”

process: bar: plugin: get source: foo process: bar: foo process: foo: plugin: machine_name source: baz bar: plugin: get source: “@foo"

slide-16
SLIDE 16

| making happiness possible axelerant.com

Process plugin: callback

  • Allows source values to be

passed to a callable

  • Prefered to use only one

argument to avoid very complex YAML

process: destination_field:

  • plugin: callback

callable:

  • '\Drupal\Component\Utility\Unicode'
  • strtolower

source: source_field

slide-17
SLIDE 17

| making happiness possible axelerant.com

Process Plugin: Concat

  • Allows to concatenate source

values for relevant D8 destination values

process: new_text_field: plugin: concat source:

  • foo
  • bar

process: new_text_field: plugin: concat source:

  • foo
  • bar

delimiter: /

slide-18
SLIDE 18

| making happiness possible axelerant.com

Process Plugin: dedupe_entity

  • dedupe_entity is used to

prevent duplication.

  • Usually used with entity types

and fields.

process: format:

  • plugin: machine_name

source: name

  • plugin: dedupe_entity

entity_type: filter_format field: format

slide-19
SLIDE 19

| making happiness possible axelerant.com

Process Plugin: dedupebase

  • Avoids duplication at the

destination

  • We can also specify a postfix

delimiter, a start position, and a length

process: new_text_field: plugin: dedupebase source: some_text_field postfix: _ start: 2 length: 6

slide-20
SLIDE 20

| making happiness possible axelerant.com

Process Plugin : default_value

  • Provides ability to set fixed

default value

  • sets the pipeline to the default

value if the pipeline has no value (NULL, zero or empty string)

process: uid:

  • plugin: migration

id: users source: author

  • plugin: default_value

default_value: 44

slide-21
SLIDE 21

| making happiness possible axelerant.com

Process Plugin : extract

  • Pulls data from potentially

multi-level arrays in the source

  • Ex: Used for Drupal 7 fields

process: new_text_field: plugin: extract source: some_text_field index:

  • und
  • value
slide-22
SLIDE 22

| 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).
slide-23
SLIDE 23

| making happiness possible axelerant.com

Process Plugin: Machine name

  • Prepares source string like

machine name

process: bar: plugin: machine_name source: foo Source: áéíK! Destination: aeik_

slide-24
SLIDE 24

| making happiness possible axelerant.com

Process plugin: Migration

  • Maintains relationship among

source and destination content in map tables.

process: uid: plugin: migration migration: users source:

  • author
slide-25
SLIDE 25

| making happiness possible axelerant.com

Process plugin : skip_process_on_empty

  • Checks whether current

pipeline is empty.

  • If so, skip processing. assign

value to destination.

process: parent:

  • plugin: skip_process_on_empty

source: parent

  • plugin: migration

migration: d6_taxonomy_term

slide-26
SLIDE 26

| making happiness possible axelerant.com

Process plugin: skip_row_if_not_set

  • Checks if value isset.
  • If set, returns value otherwise

“MigrateSkipRowException” exception

process: settings: plugin: skip_row_if_not_set index: contact source: data

slide-27
SLIDE 27

| making happiness possible axelerant.com

Process Plugin : skip_row_on_empty

  • Entire row is skipped if value is

empty

process: field_type_exists:

  • plugin: migration

migration: d6_field source:

  • field_name
  • plugin: extract

index:

  • 1
  • plugin: skip_row_on_empty
slide-28
SLIDE 28

| making happiness possible axelerant.com

Process Plugin : Static Map

  • Allows looking up a value

based on a map specified in the configuration.

process: bar: plugin: static_map source: foo map: from: to this: that

slide-29
SLIDE 29

axelerant.com | making happiness possible

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

slide-30
SLIDE 30
slide-31
SLIDE 31

| making happiness possible axelerant.com

Migrate Destination

  • Destination has mandatory

plugin key like entity: entity_type

  • URL aliases are also

exportable

destination: plugin: config config_name: book.settings

slide-32
SLIDE 32

| making happiness possible axelerant.com

Migrate destination

  • Migrate destination: component_entity_display
  • Migrate destination: component_entity_form_display
  • Migrate destination: entity:user
slide-33
SLIDE 33

| making happiness possible axelerant.com

Migrate Example

  • We will migrate users and roles from non-drupal

database to drupal 8

slide-34
SLIDE 34

| making happiness possible axelerant.com

Questions ??

slide-35
SLIDE 35

| making happiness possible axelerant.com

Thank you !!