On this page
- Note:
- Overview
- Source Code.
- migrate_ya_example/migrate_ya_example.info.yml
- migrate_ya_example/config/install/migrate_plus.migration_group.ya_example.yml
- migrate_ya_example/config/install/migrate_plus.migration.d6_file.yml
- migrate_ya_example/config/install/migrate_plus.migration.ya_user_role.yml
- migrate_ya_example/config/install/migrate_plus.migration.ya_user.yml
- migrate_ya_example/config/install/migrate_plus.migration.ya_node_page.yml
- migrate_ya_example/config/install/migrate_plus.migration.ya_node_article.yml
- Required Database Connections
- example settings.php
- Source Files
Migrating Drupal 7 Page, Article to Drupal 8 Page, Article
This documentation is deprecated.
Note:
This page describes a custom migration for migrating D7 page and article content types to D8. This custom migration is not needed. The same result can be achieved out of the box using the standard Upgrade to Drupal 8 capabilities.
---
Overview
This cookbook example shows examples of Migrating Drupal 7 Page, Article to Drupal 8 Page, Article.
Of note are :
a.) migrate_plus.migration.ya_node_page does field images migration from d7 to d8.
b.) migrate_plus.migration.ya_node_article does field entity reference from d7 to d8 making use of the migrate.process migration plugin which triangulates target_id value to its target site nid. Thus this prevents id collision and facilitates continual migration.
Source Code.
migrate_ya_example/migrate_ya_example.info.yml
name: migrate_ya_example
type: module
description: Migrate D7 content "Page and Article" to D8 content "Page and Article"
core: 8.x
package: Custom
dependencies:
- migrate_plus
- migrate_drupal
migrate_ya_example/config/install/migrate_plus.migration_group.ya_example.yml
id: ya_example
label: D7 imports
description: Migrations importing from the legacy D7 ya_example site
source_type: Drupal 7
shared_configuration:
source:
key: upgrade
migrate_ya_example/config/install/migrate_plus.migration.d6_file.yml
langcode: en
status: true
dependencies: { }
id: d6_file
migration_group: ya_example
label: Files
source:
plugin: d7_file
process:
fid: fid
filename: filename
uri: uri
filemime: filemime
status: status
created: timestamp
changed: timestamp
uid: uid
destination:
plugin: 'entity:file'
source_path_property: filepath
urlencode: true
# for the purposes of the example assumes that directory exist.
# override per environment specific through settings.local.php or settings.php
# example: $config['migrate_plus.migration']['source']['constants']['source_base_path'] = 'my/local/source/path';
source_base_path: /var/www/site/vlad_aux/d7-dev/
migration_dependencies:
required: { }
optional: { }
migrate_ya_example/config/install/migrate_plus.migration.ya_user_role.yml
langcode: en
status: true
dependencies: { }
id: ya_user_role
migration_tags: null
migration_group: ya_example
label: 'User roles'
source:
plugin: d7_user_role
process:
id:
-
plugin: machine_name
source: name
-
plugin: dedupe_entity
entity_type: user_role
field: id
length: 32
-
plugin: user_update_8002
label: name
permissions:
-
plugin: static_map
source: permissions
bypass: true
map:
'use PHP for block visibility': 'use PHP for settings'
'administer site-wide contact form': 'administer contact forms'
'post comments without approval': 'skip comment approval'
'edit own blog entries': 'edit own blog content'
'edit any blog entry': 'edit any blog content'
'delete own blog entries': 'delete own blog content'
'delete any blog entry': 'delete any blog content'
'create forum topics': 'create forum content'
'delete any forum topic': 'delete any forum content'
'delete own forum topics': 'delete own forum content'
'edit any forum topic': 'edit any forum content'
'edit own forum topics': 'edit own forum content'
-
plugin: flatten
weight: weight
destination:
plugin: 'entity:user_role'
migration_dependencies:
optional: { }
required: { }
migrate_ya_example/config/install/migrate_plus.migration.ya_user.yml
langcode: en
status: true
dependencies: { }
id: ya_user
migration_tags: null
migration_group: ya_example
label: 'User accounts'
source:
plugin: d7_user
process:
uid: uid
name: name
pass: pass
mail: mail
created: created
access: access
login: login
status: status
timezone: timezone
langcode: language
preferred_langcode: language
preferred_admin_langcode: language
init: init
roles:
plugin: migration
migration: ya_user_role
source: roles
user_picture:
-
plugin: default_value
source: picture
default_value: null
-
plugin: migration
migration: file
destination:
plugin: 'entity:user'
migration_dependencies:
required:
- ya_user_role
optional: { }
migrate_ya_example/config/install/migrate_plus.migration.ya_node_page.yml
langcode: en
status: true
dependencies: { }
id: ya_node_page
migration_tags: null
migration_group: ya_example
label: 'Nodes (Basic page)'
source:
plugin: d7_node
node_type: page
process:
nid: nid
vid: vid
langcode:
plugin: default_value
source: language
default_value: und
title: title
# references ya_user for id migration integrity
uid:
plugin: migration
migration: ya_user
source: node_uid
status: status
created: created
changed: changed
promote: promote
sticky: sticky
revision_uid:
plugin: migration
migration: ya_user
source: revision_uid
revision_log: log
revision_timestamp: timestamp
body: body
field_drupal8_images:
plugin: d6_cck_file
# migration key is not really needed plugin d6_cck_file will always look for migration name d6_file
# its hardcoded :(
migration: d6_file
source: field_drupal7_images
destination:
plugin: 'entity:node'
default_bundle: page
migration_dependencies:
required:
- d6_file
- ya_user
migrate_ya_example/config/install/migrate_plus.migration.ya_node_article.yml
langcode: en
status: true
dependencies: { }
id: ya_node_article
migration_tags: null
migration_group: ya_example
label: 'Nodes (Article)'
source:
plugin: d7_node
node_type: article
process:
nid: nid
vid: vid
langcode:
plugin: default_value
source: language
default_value: und
title: title
# by not using plugin migration, this has potential of id collisions.
uid: node_uid
status: status
created: created
changed: changed
promote: promote
sticky: sticky
revision_uid: revision_uid
revision_log: log
revision_timestamp: timestamp
body: body
# references migration ya_node_page for id migration integrity.
field_drupal8_pages:
plugin: iterator
source: field_drupal7_pages
process:
target_id:
plugin: migration
migration: ya_node_page
source: target_id
destination:
plugin: 'entity:node'
default_bundle: article
migration_dependencies:
required:
- ya_node_page
Required Database Connections
example settings.php
// Database entry needed by migrate_ya_example
// This is the source database connection d7. needs 'upgrade' key
$databases['upgrade']['default'] = array (
'database' => 'd7db',
'username' => 'vlad',
'password' => 'wibble',
'prefix' => '',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
// Database entry needed by migrate_ya_example
// This is the target database connection d8 needs 'migrate' key
$databases['migrate']['default'] = array (
'database' => 'd7d8db',
'username' => 'vlad',
'password' => 'wibble',
'prefix' => '',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
Source Files
The attached file contains migration for
Drupal 7 Page, Article to Drupal 8 Page, Article.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion