D6-D8 migration: How did we migrate Drupal 6 Body field to Drupal 8 Paragraph Type Text?
We are working on Drupal 6 to Drupal 8 site migration. One of the requirement was to migrate a Body field of Page content type to Paragraph Type Text field in Page content type.
We have used Paragraphs module to setup Paragraph Type Text field in Page content type.
Here is a step by step instructions to do the migration:
1) Firstly we enabled following contributed modules,
3) We added the Paragraph type text field in Page content type,
4) This was optional step. We specified $config_directories variable in settings.php,
8) We copied config/migrate.migration.d6_node__page.yml, it was created by 'drush config-export' command above, to config/install folder,
Mainly we changed the 'id', commented out 'uuid' and 'body' field, added our paragraph type field from page content type with process plugin. Initially we kept 'body' field uncommented for testing purposes.
9) The code in process plugin, NodeParagraphTextarea.php, looks like below,
Basically we are creating Paragraph type Text entity if it doesn't exist, otherwise we are updating it. We are also taking into account if we will add more Paragraph types in the field_page_paragraph field.
10) Finally we enabled our custom module and executed the migration,
Page migration depends upon 'd6_filter_format', 'd6_node_type', 'd6_user_role' and 'd6_user' migrations so we executed them first.
You can also run complete migration by passing '--all' option to migrate-import drush command,
The D6 site looks like,
The D8 site looks like,
We can hide 'Paragraph Textarea' label from Manage Display settings.
The custom module is hosted on github - https://github.com/amitgoyal/migrate_d6_custom
More information on executing Drupal upgrade using Drush command - https://www.drupal.org/node/2350651
We have used Paragraphs module to setup Paragraph Type Text field in Page content type.
Here is a step by step instructions to do the migration:
1) Firstly we enabled following contributed modules,
drush en migrate_upgrade migrate_tools -y2) We setup the Text Paragraphs type at /admin/structure/paragraphs_type/ and added one Textarea field at /admin/structure/types/manage/page/fields.
drush en paragraphs entity_reference_revisions -y
3) We added the Paragraph type text field in Page content type,
4) This was optional step. We specified $config_directories variable in settings.php,
$config_directories['sync'] = 'config';5) To generate the migrations for our site, we passed --configure-only option to migrate-upgrade drush command. As it indicates, our D6 site is hosted at http://d6.local:8083 and database name is d6.
drush migrate-upgrade --configure-only --legacy-db-url=mysql://drupaluser:@127.0.0.1:33067/d6 --legacy-root=http://d6.local:80836) To export the generated migrations in above step to 'config' folder on file system,
drush config-export7) We created one custom module with following files/folders,
8) We copied config/migrate.migration.d6_node__page.yml, it was created by 'drush config-export' command above, to config/install folder,
cp config/migrate.migration.d6_node__page.yml modules/custom/migrate_d6_custom/config/install/migrate.migration.d6_node__page_custom.ymland the .yml file looks like below,
Mainly we changed the 'id', commented out 'uuid' and 'body' field, added our paragraph type field from page content type with process plugin. Initially we kept 'body' field uncommented for testing purposes.
9) The code in process plugin, NodeParagraphTextarea.php, looks like below,
Basically we are creating Paragraph type Text entity if it doesn't exist, otherwise we are updating it. We are also taking into account if we will add more Paragraph types in the field_page_paragraph field.
10) Finally we enabled our custom module and executed the migration,
drush en migrate_d6_custom -y
drush migrate-import d6_filter_format
drush migrate-import d6_node_type
drush migrate-import d6_user_role
drush migrate-import d6_user
drush migrate-import d6_node__page_custom
Page migration depends upon 'd6_filter_format', 'd6_node_type', 'd6_user_role' and 'd6_user' migrations so we executed them first.
You can also run complete migration by passing '--all' option to migrate-import drush command,
drush migrate-import --all
The D6 site looks like,
The D8 site looks like,
We can hide 'Paragraph Textarea' label from Manage Display settings.
The custom module is hosted on github - https://github.com/amitgoyal/migrate_d6_custom
More information on executing Drupal upgrade using Drush command - https://www.drupal.org/node/2350651








Comments