D6-D8 migration: Migration of Drupal 6 Images (Image module) to Drupal 8 Images
As per D6-D8 migration: Migration of Drupal 6 Images (ImageField module) to Drupal 8 Images works out of the Box!, we tried to migrate images from D6 site, which is using Image module, but the images didn't get migrated.
So images uploaded using Image module along with it's sub module image_attach in D6 content type don't migrate out of the box.
We used following steps to migrate the Images from D6 to D8 site:
1) Firstly we setup the D6 site by enabling contributed Image module along with it's sub module image_attach. And then we enabled images support for Page content type like below,
2) Next we added the content in page content type with multiple images in D6 site. Our D6 site looks like below,
3) Next we setup D8 site and added Image field (field_page_image) in Page content type. We enabled Drupal Upgrade and Migrate Tools contrib modules for the migration,
8) We copied config/migrate.migration.d6_node__page.yml, it was created by 'drush config-export' command above, to config/install folder,
Basically this code runs only for our custom node page migration and it loads all the images from D6 database for the given node. Then it builds up the array as required by d6_cck_plugin as used in step 8 above. Finally it creates one field in source row called 'field_page_image'.
10) Finally we enabled our custom module and executed the migration,
You can also run complete migration by passing '--all' option to migrate-import drush command and this will take care of running the migrations in required order,
The D8 site has content and images both,
The custom module is hosted on github - https://github.com/amitgoyal/migrate_d6_image_custom
You can find more information on how to execute Drupal upgrade using Drush command here - https://www.drupal.org/node/2350651
Please feel free to let us know if there are better ways of doing it by adding your comments!
So images uploaded using Image module along with it's sub module image_attach in D6 content type don't migrate out of the box.
We used following steps to migrate the Images from D6 to D8 site:
1) Firstly we setup the D6 site by enabling contributed Image module along with it's sub module image_attach. And then we enabled images support for Page content type like below,
2) Next we added the content in page content type with multiple images in D6 site. Our D6 site looks like below,
3) Next we setup D8 site and added Image field (field_page_image) in Page content type. We enabled Drupal Upgrade and Migrate Tools contrib modules for the migration,
drush en migrate_upgrade migrate_tools -y4) 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-export sync7) We created one custom module, migrate_d6_image_custom, with the 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.ymlWe changed the 'id' to 'd6_node__page_custom' and added Image field mapping like below,
field_page_image:9) Next we added hook_migrate_prepare_row() in our migrate_d6_image_custom.module file. The code looks like below,
plugin: d6_cck_file
source: field_page_image
Basically this code runs only for our custom node page migration and it loads all the images from D6 database for the given node. Then it builds up the array as required by d6_cck_plugin as used in step 8 above. Finally it creates one field in source row called 'field_page_image'.
10) Finally we enabled our custom module and executed the migration,
drush en migrate_d6_image_custom -y
drush migrate-import d6_file
drush migrate-import d6_filter_formatWe have to migrate the images first so we executed the file migration first. Page migration depends upon 'd6_filter_format', 'd6_node_type', 'd6_user_role' and 'd6_user' migrations so we executed them first.
drush migrate-import d6_node_type
drush migrate-import d6_user_role
drush migrate-import d6_user
drush migrate-import d6_node__page_custom
You can also run complete migration by passing '--all' option to migrate-import drush command and this will take care of running the migrations in required order,
drush migrate-import --all
The D8 site has content and images both,
The custom module is hosted on github - https://github.com/amitgoyal/migrate_d6_image_custom
You can find more information on how to execute Drupal upgrade using Drush command here - https://www.drupal.org/node/2350651
Please feel free to let us know if there are better ways of doing it by adding your comments!





Comments