drupal migrate-june2015
TRANSCRIPT
INTRODUCTION TO MIGRATE (FOR SITE BUILDERS)
• Drupal consulting, development, and training
• Founded in 2007 by Alex and Suzanne
• Help organizations build awesome Drupal websites with custom functionality
About me
Projects
What is Migrate?
Migration Methods• Migration by hand
• Node export module
• Feeds module
• Create a custom migration script
• Use the migrate module
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
Sources• D6 or D7 site
• CSV file
• YAML
• JSON
• XML
• etc.
What you need to know• Site Building (how content types work)
• Love working with data
• Tiny bit of Drush
• Write a simple module
MIGRATING FROM A CSV
Basic steps1. Preparing the site & content
2. Create your migrate module
3. Run the migrations
4. Testing and iterating
Preparing Your Site & the Content
Modules for the Demo• Migrate, Migrate D2D
• Entity, Entity Reference
• Bundle Copy to create the content type
• Ctools, Views
• Migrate Programs (custom)
Setting up Content Types
Prepare your CSV
Lining up the Columns
Creating Your Migrate Module
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
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
Creating a Migrate Modulemigrate_programs.module//Nothing to see here!
Registering my Migrationsmigrate_programs.migrate.inc
http://bit.ly/migrate-programs-inc
Extending Migration Classmigrate_programs.migrate.inc
http://bit.ly/migrate-programs-inc
Source and Destinationmigrate_programs.migrate.inc
http://bit.ly/migrate-programs-inc
in the __construct function
Field Mappingin the __construct function
Selecting Columns
Preprocessing Data
Install File
http://bit.ly/migrate-programs-install
migrate_programs.install
Running Your Migrations
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
Testing and Iterating!
Testing and Iterating
Testing and Iterating
Migrating other Fields
Mapping Attributes for Image Fields
Entity referencesMapping the reference field (tell Drupal where to get the data from)
Dummy nodes for self-referencing fields
MIGRATING FROM DRUPAL
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
Database InfoContent > Migrate > Import from Drupal
Importing Users
Importing Taxonomy
Importing Files
Importing Content
Migrate Status
Mapping
HOW THIS WORKS IN DRUPAL 8
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
Thanks & QA