drupal migrate-june2015

46
INTRODUCTION TO MIGRATE (FOR SITE BUILDERS)

Upload: suzanne-dergacheva

Post on 14-Apr-2017

451 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Drupal migrate-june2015

INTRODUCTION TO MIGRATE (FOR SITE BUILDERS)

Page 2: Drupal migrate-june2015

• Drupal consulting, development, and training

• Founded in 2007 by Alex and Suzanne

• Help organizations build awesome Drupal websites with custom functionality

About me

Page 3: Drupal migrate-june2015

Projects

Page 4: Drupal migrate-june2015

What is Migrate?

Page 5: Drupal migrate-june2015

Migration Methods• Migration by hand

• Node export module

• Feeds module

• Create a custom migration script

• Use the migrate module

Page 6: Drupal migrate-june2015

The Migrate module• Imports content from various sources

• Works with nodes, taxonomy terms, users, etc.

• Allows you to migrate content, and then rollback to remove what you added

• You have to write some code to run migrations

Page 7: Drupal migrate-june2015

Sources• D6 or D7 site

• CSV file

• YAML

• JSON

• XML

• etc.

Page 8: Drupal migrate-june2015

What you need to know• Site Building (how content types work)

• Love working with data

• Tiny bit of Drush

• Write a simple module

Page 9: Drupal migrate-june2015

MIGRATING FROM A CSV

Page 10: Drupal migrate-june2015

Basic steps1. Preparing the site & content

2. Create your migrate module

3. Run the migrations

4. Testing and iterating

Page 11: Drupal migrate-june2015

Preparing Your Site & the Content

Page 12: Drupal migrate-june2015

Modules for the Demo• Migrate, Migrate D2D

• Entity, Entity Reference

• Bundle Copy to create the content type

• Ctools, Views

• Migrate Programs (custom)

Page 13: Drupal migrate-june2015

Setting up Content Types

Page 14: Drupal migrate-june2015

Prepare your CSV

Page 15: Drupal migrate-june2015

Lining up the Columns

Page 16: Drupal migrate-june2015

Creating Your Migrate Module

Page 17: Drupal migrate-june2015

Anatomy of Your Migrate Module

trent_migrate_programs.migrate.inc

trent_migrate_programs.module

trent_migrate_programs.info

trent_migrate_programs.install

header-images

programs.csv

Source files

Module files

Page 18: Drupal migrate-june2015

Creating a Migrate Module

name = Migrate Programs

description = Migrate program information from CSV

core = 7.x

dependencies[] = migrate

dependencies[] = entityreference

dependencies[] = link

dependencies[] = email

files[] = migrate_programs.migrate.inc

migrate_programs.info

Page 19: Drupal migrate-june2015

Creating a Migrate Modulemigrate_programs.module//Nothing to see here!

Page 20: Drupal migrate-june2015

Registering my Migrationsmigrate_programs.migrate.inc

http://bit.ly/migrate-programs-inc

Page 21: Drupal migrate-june2015

Extending Migration Classmigrate_programs.migrate.inc

http://bit.ly/migrate-programs-inc

Page 22: Drupal migrate-june2015

Source and Destinationmigrate_programs.migrate.inc

http://bit.ly/migrate-programs-inc

in the __construct function

Page 23: Drupal migrate-june2015

Field Mappingin the __construct function

Page 24: Drupal migrate-june2015

Selecting Columns

Page 25: Drupal migrate-june2015

Preprocessing Data

Page 26: Drupal migrate-june2015

Install File

http://bit.ly/migrate-programs-install

migrate_programs.install

Page 27: Drupal migrate-june2015

Running Your Migrations

Page 28: Drupal migrate-june2015

Drush Commandsdrush migrate-register programs

drush migrate-import programs

drush migrate-import programs --update

drush migrate-rollback programs

drush migrate-stop programs

drush migrate-deregister programs

https://www.drupal.org/node/1561820

Page 29: Drupal migrate-june2015

Testing and Iterating!

Page 30: Drupal migrate-june2015

Testing and Iterating

Page 31: Drupal migrate-june2015

Testing and Iterating

Page 32: Drupal migrate-june2015

Migrating other Fields

Page 33: Drupal migrate-june2015

Mapping Attributes for Image Fields

Page 34: Drupal migrate-june2015

Entity referencesMapping the reference field (tell Drupal where to get the data from)

Dummy nodes for self-referencing fields

Page 35: Drupal migrate-june2015

MIGRATING FROM DRUPAL

Page 36: Drupal migrate-june2015

Setup• Used bundle copy to create the program

content type on migrate-demo2• Installed Migrate D2D on migrate-demo2• Looked up my database credentials from

migrate-demo

Page 37: Drupal migrate-june2015

Database InfoContent > Migrate > Import from Drupal

Page 38: Drupal migrate-june2015

Importing Users

Page 39: Drupal migrate-june2015

Importing Taxonomy

Page 40: Drupal migrate-june2015

Importing Files

Page 41: Drupal migrate-june2015

Importing Content

Page 42: Drupal migrate-june2015

Migrate Status

Page 43: Drupal migrate-june2015

Mapping

Page 44: Drupal migrate-june2015

HOW THIS WORKS IN DRUPAL 8

Page 45: Drupal migrate-june2015

Drupal 8 Migrate• Migrate and Migrate Drupal core modules• No need to create content types• Works with content and configuration• Currently works for D6 to D8, D7 to D8 in progress• No more upgrading using update.php• You can create manifest.yml to define a migration• Migrate Upgrade module (contrib) provides a UI

for Drupal to Drupal migrations

https://www.drupal.org/node/2350521

Page 46: Drupal migrate-june2015

Thanks & QA