Top Banner
Getting Stuff Into Drupal Basics of Content Migration Michael Anello DrupalEasy
43

Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Jun 07, 2018

Download

Documents

doankhuong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Getting Stuff Into DrupalBasics of Content Migration

Michael AnelloDrupalEasy

Page 2: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Who am I?

• Michael Anello

• Co-founder, DrupalEasy

• Co-host, DrupalEasy Podcast

• Drupal trainer and developer

• @ultimike

Page 3: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

For most of us, when we first learn Drupal...

Page 4: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Content types

Page 5: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Taxonomy

Page 6: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Views

Page 7: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Theming

Page 8: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s
Page 9: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s
Page 10: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s
Page 11: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s
Page 12: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

What options are there for getting existing

content onto a new site?

Page 13: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s
Page 15: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

http://www.pozadzides.com/photos/bladesmithing/hammers_medres.jpg

Comparison of some of the Drupal import/export tools: https://groups.drupal.org/node/21338

Page 16: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Feedshttp://www.drupal.org/project/feeds

Page 17: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migratehttp://www.drupal.org/project/migrate

Page 18: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Drupal-to-Drupal data migration

http://www.drupal.org/project/d2d_migrate

(Migrate D2D)

Page 19: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

???

Page 21: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Not too much content Manual

Content in flat files (.xls, .csv, .xml)

Feeds/Migrate

Content in non-Drupal database

Migrate

Content in previous version of Drupal

Migrate D2D

Page 22: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Data migration project assumptions

Page 23: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migration Assumptions

1. The data is never as clean as it is claimed to be.

2. Data will almost always need to be “massaged” during migration.

3. You don’t know half of what you need to know to complete the migration until you’re in the middle of the migration.

Page 24: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

The Process

Page 25: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

The Process

• Analyze - understand the legacy data

• Map - line up the pegs with the holes

• Iterate - implement, test, refine, repeat

• Launch!

From Mike Ryan and Moesh Weitzman’s “Migration: Smoothing the Move” DrupalCon Denver 2012 session.http://www.youtube.com/watch?v=1sYqsNEt6Jo

Communication is key!

Page 26: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

The Process

Source

Field 1Field 2Field 3Field 4Field 5

Destination

Field 1Field 2Field 3Field 4

POOF!

Page 27: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Feeds Module

Page 28: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Feeds Module

• Takes a flat file as input (periodically or on-demand)

• Imports from URL or file upload

• Parses file (.csv, .xml)

• Processes data (maps data to user, taxonomy, or node fields)

Page 29: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Feeds Module• Flexible

• Works with any well-defined .xml

• Numerous options for parsers

• Data can be “massaged”

• Rules integration

• Feeds Tamper module

• No code*

*depending on level of “massaging”

Page 30: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

ProcessorFetcher + Parser

The Process - Feeds

Source

Field 1Field 2Field 3Field 4Field 5

Destination

Field 1Field 2Field 3Field 4

POOF!

Page 31: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Feeds Module Example

Farmers’ Markets

Page 32: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate Module

Page 33: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate Module

• A custom module must be written

• Better for data that references itself

• Create “migration classes” to identify source, destination, mapping, massaging

• Migrations can be rolled-back

• Continuous migration available

• Extensible

Page 34: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate Module

• Unbelievably flexible

• Best for importing data from other databases

• Significant learning curve

• Great Drush integration

• Used for giant data migration projects

• Lots of (object-oriented) code

Page 35: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate Module - Drush

• migrate-import [migration_name]

• migrate-import --rollback --all

• migrate-import --update [migrationname]

• migrate-rollback [migration_name]

• many others at https://drupal.org/node/1561820

Page 36: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migration class

Map class

Destination classSource class

The Process - Migrate

Source

Field IDField 1Field 2Field 3Field 4Field 5

Destination

Field IDField 1Field 2Field 3Field 4

Field Mapping class

Field Mapping class

From Andrew Morton’s “Getting it into Drupal with Migrate” DrupalCon Denver 2012 session. http://denver2012.drupal.org/sites/default/files/Migrate.pdf

Field Mapping class

Page 37: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

The Process - Migrate

From Andrew Morton’s “Getting it into Drupal with Migrate” DrupalCon Denver 2012 session. http://denver2012.drupal.org/sites/default/files/Migrate.pdf

class FirstMigration extends Migration { public function __construct() { parent::__construct();

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

$this->destination = new MigrateDestinationNode(‘basic_page’);

$this->map = new MigrationSQLMap(...);

$this->addFieldMapping(‘dest_name’, ‘source_name’)->defaultValue(1); }}

Page 38: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate Module Example

JeepNewsNow.com

Page 39: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate Module - Gotchas!

• Don’t “drush migrate-deregister” a migration without rolling back first.

• Rollback prior to making any major changes to your migration class - especially if you’re modifying the source query.

• Clear caches after creating new migration classes.

Page 40: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate D2D Module

Page 41: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate D2D Module

• A great way to migrate and rebuild an older Drupal site

• All the same benefits of the Migrate module

• Provides migration classes specific to migrating from older versions of Drupal

Page 42: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Migrate D2D Module Example

DrupalEasy.com

Page 43: Getting Stuff Into Drupaldrupaleasy.com/.../drupaleasy.com/files/getting_stuff_into_drupal.pdf · Getting Stuff Into Drupal ... Theming. What options are ... From Andrew Morton’s

Thank you!

Michael Anello@ultimike

http://drupaleasy.com/