Transcript
Page 1: Data migration to Drupal using the migrate module

Data Migration with Drupal using Migrate

Drupal を使ったデータ移行について

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.12th April 2014 - Luc Bézier, @Luukyb

Drupalcamp Kyoto, Japan

https://www.flickr.com/photos/lifes26/4509331619/

Page 2: Data migration to Drupal using the migrate module

Who am I

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Page 3: Data migration to Drupal using the migrate module

Who am I

Freelance web, exclusively Drupal projects since ~ 4 years.

I moved to Cebu City, Philippines ~ 1 year.

Twitter @[email protected]

Luukyb on drupal.org

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Page 4: Data migration to Drupal using the migrate module

Who am I

Contributed to several large data migrationto drupal using migrate module.

Oracle to drupal :BBC Good Food

UK public sector organisation

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Page 5: Data migration to Drupal using the migrate module

http://www.flickr.com/photos/larahsphotography/2795859728/

1. Introduction to data migration2. Understanding the migrate module

3. Organise your Data migration with Migrate4. Migrate in Drupal 8

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Page 6: Data migration to Drupal using the migrate module

Data migration

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 7: Data migration to Drupal using the migrate module

Data migration

Moving data from A to B

(and often, in the middle you transform the data.)

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 8: Data migration to Drupal using the migrate module

Data migration

Simple migration?Feeds module

Data mapping using UI.drupal.org/project/feeds

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 9: Data migration to Drupal using the migrate module

Data migration

Use migrate module for a complex migration.

Complex source or destination.

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 10: Data migration to Drupal using the migrate module

Data migration

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/kieranlane/6635502419/

Page 11: Data migration to Drupal using the migrate module

Data migration

Using the migrate module can require code, coffee

and patience.

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/kieranlane/6635502419/

Page 12: Data migration to Drupal using the migrate module

Data migration

Good news:Migrate module is very flexible, powerful and well documented.

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 13: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Page 14: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Drupal module

Install and enable like any other contrib module

drupal.org/project/migrate

Page 15: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Created by Mike Ryan.drupal.org/user/4420

Senior Technical Consultantat Acquia

Page 16: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

“framework for migrating content into Drupal from other

sources”

Page 17: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

What’s inside ?- OOP Architecture

- An API- Some drush commands

- Migrate UI

Page 18: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Built-in support of core items (Nodes, Users, Files, Taxonomy

and comments)

Page 19: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Built-in support for PDO, XML, CSV, JSON, and native MSSQL

and Oracle API sources

Page 20: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

You can extend all sources, destinations.

Page 21: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Migration:- 100% native drupal

- iterative

Page 22: Data migration to Drupal using the migrate module

Introduction to Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Related modules:- Drupal-to-Drupal data migration (migrate_d2d)

- WordPress Migrate- TYPO3_migrate

Page 23: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Page 24: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Your migration classes extends the

abstract class Migration

Page 25: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Your source.

$this->source = new MigrateSourceSQL($query);

Page 26: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Your destination.

$this->destination = new MigrateDestinationNode(’article');

Page 27: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Your mapping.

$this->addFieldMapping('field_summary', 'summary');

Page 28: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Transform your data.

$this->addFieldMapping('field_summary', 'summary’)

->callbacks(array($this, ’summaryFormat'));

Page 29: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Extra transformation and processing can be done using

methods like:function prepareRow($row)

Page 30: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Some cool features !Source dependency definition.

$this->addFieldMapping('field_image', ’imagepath') ->sourceMigration(’MediaImages');

Page 31: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Easy to rollback the data.When you run a migration,

migrate module stores the keys.

Page 32: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

If you import into a contributed module: 2 cases.

Page 33: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

First case, my contrib module does not support migrate.

Page 34: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Example: Media module.

Migrating content for the media module requires migrate_extras.

Page 35: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Migrate extras module implements extra support.

drupal.org/project/migrate_extras

Page 36: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Module maintainers are now recommended to implement

migration directly in the modules.

Page 37: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

So second case, my contrib module implements migrate.

Page 38: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Example: field collection.

Comes with a file dedicated to migrate:

field_collection.migrate.inc

Page 39: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Use drush !

Limit the number of items to import,Rollback the data,

Audit your migration, …

Page 40: Data migration to Drupal using the migrate module

Understanding Migrate module

http://www.flickr.com/photos/zigazou76/9104028602

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

Page 41: Data migration to Drupal using the migrate module

Organise your Data migration

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 42: Data migration to Drupal using the migrate module

Organise your Data migration

Study the source data,keep track of the changes.

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 43: Data migration to Drupal using the migrate module

Organise your Data migration

Use a separate migration environment.

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 44: Data migration to Drupal using the migrate module

Organise your Data migration

Use a script to build this environment from scratch.

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 45: Data migration to Drupal using the migrate module

Organise your Data migration

Install your site with a profile$ drush si profileMigrate the data

$ drush mi MyMigration

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/usace_albuquerque/5547589951/

Page 46: Data migration to Drupal using the migrate module

Migrate to D8

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/michaeljohn/306759922/

Page 47: Data migration to Drupal using the migrate module

Migrate to D8

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/michaeljohn/306759922/

Drupal 8 will integrate a Migration API to migrate your site from

Drupal 6 and Drupal 7 to Drupal 8.

Page 48: Data migration to Drupal using the migrate module

Migrate to D8

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/michaeljohn/306759922/

This API will be based on migrate module.(currently still in progress)

Page 49: Data migration to Drupal using the migrate module

Migrate to D8

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/michaeljohn/306759922/

Migration API in D8:drupal.org/node/2127611

Migration modules list :drupal.org/documentation/migrate

Page 50: Data migration to Drupal using the migrate module

Questions?

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/michaeljohn/306759922/

Page 51: Data migration to Drupal using the migrate module

Coming camps in PHL

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/michaeljohn/306759922/

Drupalcamp Manila : 26th April

Drupalcamp Cebu : October 2014 (TBC)

Page 52: Data migration to Drupal using the migrate module

Thank you !

Data Migration with Drupal using Migrate, Drupalcamp Kyoto.Luc Bézier, @Luukyb

https://www.flickr.com/photos/michaeljohn/306759922/

ありがとう[email protected]

@luukyb


Recommended