Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Migration from Drupal 6 to Drupal 8
My first Drupal 8 migration
Created by / Drupal developerIvan Abramenko CimpleO
ceservices.com
Drupal 8.0.x
Migrate Upgrade / Drupal Upgrade
https://www.drupal.org/project/migrate_upgrade
Drupal Upgrade - Drupal 8.1.x...
Drupal 8.1.x migration
Migrate UI didn't work for Drupal 8.1.x and above
https://www.drupal.org/project/migrate_ui
Migrati...
Drupal 8.2.x migration
Migrate Drupal UI in core!
Works, but not perfect.
Drupal 8.0.x migration
Drupal 8.0.x => Drupal 8.1.x => Drupal 8.2.x
Uninstall drupal migrate modules after migration and b...
Why should use migrate module?
Migrate map
Import/Rollback
Stub content
Migrate import (drush support)
With Migrate Tools ...
Prepare migrations to import
            drush migrate­upgrade 
            ­­legacy­db­url=mysql://user:password@localhos...
Drupal Upgrade module:
Drupal Upgrade
Successfully migrated:
User roles
Users
Node types (needed static map)
Failed with:
Nodes
Node types (needed static map)
blog_entry ­> blog_post
lp         ­> landing_page
2 ways to resolve it:
Add static map for...
Process pipeline
Process pipeline
https://www.drupal.org/node/2129651
Plugins in Migrate UI:
static map
migration
explode
iterator
callback
concat
dedupe_entity
dedupebase
default_value
extract
atten
machine_name
sk...
Custom plugins
/modules/ceservices_migrate/src/Plugin/migrate/process/CeservicesFieldsType.php
<?php 
/** 
* @file 
* Cont...
Custom plugins
/modules/ceservices_migrate/src/Plugin/migrate/process/CeservicesNodeTypes.php
<?php 
/** 
* @file 
* Conta...
UI doesn't work as you want
https://www.drupal.org/node/2708967
UI doesn't work as you want
https://www.drupal.org/node/2708967
migrate.migration.d6_node_type.yml
... 
process: 
  type: ...
Custom migrations are better than Migrate
Upgrade
Custom migrations
Nodes
Taxonomy
Nodewords, Page Title to Metatag
Nodes migration
YML- le for each content type:
/modules/ceservices_migrate/con g/install/
              
migrate.migration...
migrate.migration.ceservices_blog.yml:
id: ceservices_blog 
label: Blog nodes migration from Drupal 6 
dependencies: 
  en...
Source => Destination
              
source: 
  plugin: ceservices_blog 
destination: 
  plugin: entity:node 
            ...
Source plugin
Custom plugin or d6_node?
Our choice is custom one. Extend DrupalSqlBase class, not
Node class for Drupal 6.
Blog source plugin
/modules/ceservices_migrate/src/Plugin/migrate/source/CeservicesBlog.php
<?php 
/** 
* @file 
* Contain...
Why did we use DrupalSqlBase instead of
SourcePluginBase or SqlBase?
Blog source plugin's methods
query()
public function query() { 
  $query = $this­>select('node', 'n') 
    ­>condition('n.type', 'blog') 
    ­>fields(...
fields()
public function fields() { 
  $fields = $this­>baseFields(); 
  $fields['body/format'] = $this­>t('Format of body...
prepareRow(Row $row)
public function prepareRow(Row $row) { 
  $nid = $row­>getSourceProperty('nid'); 
  // body (compound...
Single value fields:
$row­>setSourceProperty('body_value', $record­>body);
Multiple values fields:
// Multiple fields. 
$r...
And few methods to describe entity:
public function getIds() { 
  $ids['nid']['type'] = 'integer'; 
  $ids['nid']['alias']...
Process — map between
destination => source
process: 
  nid: nid 
  vid: vid 
  type: type 
  langcode: 
    plugin: stati...
We decided to use old nid/vid values:
              
                process: 
                nid: nid 
                v...
Use batch API for any problems after
migration
Nodewords, Page Title:
https://www.drupal.org/node/2052441
https://www.drup...
Thank you! And successful migrations!
Migration from Drupal 6 to Drupal 8
My first Drupal 8 migration
Created by / Drupal ...
Upcoming SlideShare
Loading in …5
×

Migrate drupal 6 to drupal 8. Абраменко Иван

162 views

Published on

Абраменко Иван выступил с темой “Migrate drupal 6 to drupal 8” на Drupal Cafe #18

Видео с выступления вы можете увидеть, перейдя по ссылке https://youtu.be/kC5U7PKHu7c?list=PLtUZRIj1OWYzCGb3OCYMVYqnrJ-EpH0Ot

Published in: Internet
  • Be the first to comment

  • Be the first to like this

Migrate drupal 6 to drupal 8. Абраменко Иван

  1. 1. Migration from Drupal 6 to Drupal 8 My first Drupal 8 migration Created by / Drupal developerIvan Abramenko CimpleO
  2. 2. ceservices.com
  3. 3. Drupal 8.0.x Migrate Upgrade / Drupal Upgrade https://www.drupal.org/project/migrate_upgrade Drupal Upgrade - Drupal 8.1.x Migrate Drupal UI - Drupal 8.2.x
  4. 4. Drupal 8.1.x migration Migrate UI didn't work for Drupal 8.1.x and above https://www.drupal.org/project/migrate_ui Migrations are core are now plugins, not con g entities. https://www.drupal.org/node/2677198 https://www.drupal.org/node/2625696 Try to use Migrate Drupal UI core module for Drupal 8.2.x and above.
  5. 5. Drupal 8.2.x migration Migrate Drupal UI in core! Works, but not perfect.
  6. 6. Drupal 8.0.x migration Drupal 8.0.x => Drupal 8.1.x => Drupal 8.2.x Uninstall drupal migrate modules after migration and before update to 8.1.x!
  7. 7. Why should use migrate module? Migrate map Import/Rollback Stub content Migrate import (drush support) With Migrate Tools module https://www.drupal.org/project/migrate_tools drush migrate­import migration_name  drush migrate­rollback migration_name            
  8. 8. Prepare migrations to import             drush migrate­upgrade              ­­legacy­db­url=mysql://user:password@localhost:3306/db              ­­legacy­db­prefix=drup_              ­­legacy­root=http://www.ceservices.com              ­­configure­only            
  9. 9. Drupal Upgrade module:
  10. 10. Drupal Upgrade Successfully migrated: User roles Users Node types (needed static map) Failed with: Nodes
  11. 11. Node types (needed static map) blog_entry ­> blog_post lp         ­> landing_page 2 ways to resolve it: Add static map for migration .yml le Add custom plugin
  12. 12. Process pipeline
  13. 13. Process pipeline https://www.drupal.org/node/2129651 Plugins in Migrate UI:
  14. 14. static map migration explode iterator callback concat dedupe_entity dedupebase default_value extract atten machine_name skip_on_empty skip_row_if_not_set
  15. 15. Custom plugins /modules/ceservices_migrate/src/Plugin/migrate/process/CeservicesFieldsType.php <?php  /**  * @file  * Contains Drupalceservices_migratePluginmigrateprocessCeservicesFieldsType */  namespace Drupalceservices_migratePluginmigrateprocess;  use DrupalmigrateProcessPluginBase;  use DrupalmigrateMigrateExecutableInterface;  use DrupalmigrateRow;  /**  * This plugin replaces old node_types with new.  *  * @MigrateProcessPlugin(  *   id = "ceservices_fields_type" 
  16. 16. Custom plugins /modules/ceservices_migrate/src/Plugin/migrate/process/CeservicesNodeTypes.php <?php  /**  * @file  * Contains Drupalceservices_migratePluginmigrateprocessCeservicesNodeTypes. */  namespace Drupalceservices_migratePluginmigrateprocess;  use DrupalmigrateProcessPluginBase;  use DrupalmigrateMigrateExecutableInterface;  use DrupalmigrateRow;  /**  * This plugin replaces old node_types with new.  *  * @MigrateProcessPlugin(  *   id = "ceservices_node_types" 
  17. 17. UI doesn't work as you want https://www.drupal.org/node/2708967
  18. 18. UI doesn't work as you want https://www.drupal.org/node/2708967 migrate.migration.d6_node_type.yml ...  process:    type:      plugin: static_map      source: type      map:        blog_entry: blog  ...
  19. 19. Custom migrations are better than Migrate Upgrade
  20. 20. Custom migrations Nodes Taxonomy Nodewords, Page Title to Metatag
  21. 21. Nodes migration YML- le for each content type: /modules/ceservices_migrate/con g/install/                migrate.migration.ceservices_blog.yml  migrate.migration.ceservices_book.yml  migrate.migration.ceservices_page.yml  migrate.migration.ceservices_story.yml  ...                             
  22. 22. migrate.migration.ceservices_blog.yml: id: ceservices_blog  label: Blog nodes migration from Drupal 6  dependencies:    enforced:      module:       ­ ceservices_migrate  source:    plugin: ceservices_blog  destination:    plugin: entity:node  process:    nid: nid    vid: vid    type: type    langcode:      plugin: static_map      bypass: true 
  23. 23. Source => Destination                source:    plugin: ceservices_blog  destination:    plugin: entity:node                             
  24. 24. Source plugin Custom plugin or d6_node? Our choice is custom one. Extend DrupalSqlBase class, not Node class for Drupal 6.
  25. 25. Blog source plugin /modules/ceservices_migrate/src/Plugin/migrate/source/CeservicesBlog.php <?php  /**  * @file  * Contains Drupalceservices_migratePluginmigratesourceCeservicesBlog. */  namespace Drupalceservices_migratePluginmigratesource;  use DrupalmigrateRow;  use Drupalmigrate_drupalPluginmigratesourceDrupalSqlBase;  /**  * Drupal 6 Blog node source plugin  *  * @MigrateSource(  *   id = "ceservices_blog" 
  26. 26. Why did we use DrupalSqlBase instead of SourcePluginBase or SqlBase?
  27. 27. Blog source plugin's methods
  28. 28. query() public function query() {    $query = $this­>select('node', 'n')      ­>condition('n.type', 'blog')      ­>fields('n');    $query­>orderBy('nid');    return $query;  } 
  29. 29. fields() public function fields() {    $fields = $this­>baseFields();    $fields['body/format'] = $this­>t('Format of body');    $fields['body/value'] = $this­>t('Full text of body');    $fields['body/summary'] = $this­>t('Summary of body');    $fields['field_related_testimonial'] = $this­>t('Related testimonial');    $fields['field_related_resources'] = $this­>t('Related Resources');    $fields['field_related_blog'] = $this­>t('Related Blog Posts');    $fields['field_taxonomy'] = $this­>t('Taxonomy');    return $fields;  }              
  30. 30. prepareRow(Row $row) public function prepareRow(Row $row) {    $nid = $row­>getSourceProperty('nid');    // body (compound field with value, summary, and format)    $result = $this­>getDatabase()­>query('      SELECT      *      FROM      {node_revisions} n      INNER JOIN {node} node ON n.vid = node.vid      LEFT JOIN {content_type_blog} t ON t.vid = n.vid      LEFT JOIN {content_field_related_testimonial} r ON r.vid = n.vid      WHERE      n.nid = :nid      LIMIT 0, 1      ', array(':nid' => $nid));    foreach ($result as $record) { 
  31. 31. Single value fields: $row­>setSourceProperty('body_value', $record­>body); Multiple values fields: // Multiple fields.  $result = $this­>getDatabase()­>query('    SELECT    *    FROM    {content_field_related_resources} r    INNER JOIN {node} node ON r.vid = node.vid    WHERE    r.nid = :nid    ', array(':nid' => $nid));  $related_resources = [];  foreach ($result as $record) {    if (!empty($record­>field_related_resources_nid)) {      $related_resources[] = $record­>field_related_resources_nid;    }  }  $row­>setSourceProperty('field_related_resources', $related_resources); 
  32. 32. And few methods to describe entity: public function getIds() {    $ids['nid']['type'] = 'integer';    $ids['nid']['alias'] = 'n';    return $ids;  }  public function bundleMigrationRequired() {    return FALSE;  }  public function entityTypeId() {    return 'node';  }              
  33. 33. Process — map between destination => source process:    nid: nid    vid: vid    type: type    langcode:      plugin: static_map      bypass: true      source: language      map:        und: en        en: en    title: title    uid: uid    status: status    created: created    changed: changed    promote: promote 
  34. 34. We decided to use old nid/vid values:                                process:                  nid: nid                  vid: vid                              Be sure you deleted all content before migration!
  35. 35. Use batch API for any problems after migration Nodewords, Page Title: https://www.drupal.org/node/2052441 https://www.drupal.org/node/2563649
  36. 36. Thank you! And successful migrations! Migration from Drupal 6 to Drupal 8 My first Drupal 8 migration Created by / Drupal developerIvan Abramenko CimpleO levmyshkin89@gmail.com

×