Cookbook

A cookbook of tips and ideas for Drupal-to-Drupal Migrations. See sub-pages for recipes.

Migrating to Drupal 7

Cover image for this book
Sub-title: 
Learn how to quickly and efficiently migrate content into Drupal 7 from a variety of sources including Drupal 6 using automated migration and import processes.
Authors: 
Publisher: 
Packt Publishing
Publication date: 
2012-12
Page count: 
158
ISBN-13: 
9781782160540

What you will learn from this book

  • Configure your Drupal site to run imports of migrated content using the Feeds module
  • Run an import of migrated content using Feeds module and a Feed importer
  • Package your configuration using the Features module
  • Utilize the Migrate module and its benefits
  • Migrate blog posts from WordPress to Drupal
  • Upgrade your Drupal 6 site to Drupal 7
  • Configure the Feeds Tamper module to preprocess your Feeds imports
  • Run additional imports using the Feeds modules to update and add new data and content to your Drupal site

In Detail

This book will show you how to migrate your content into the Drupal content management system. You’ll start by building a content type in Drupal to hold your migrated content. You’ll then import your content into Drupal using the Feeds module. In order to be able to easily use them again and again, you will also learn the best methods of maintaining and packaging migration configurations.

In "Migrating to Drupal 7" you’ll learn how to quickly package your legacy site’s data into a format that’s easy to import into Drupal. You’ll then build a content type to hold migrated data in Drupal. To save time and hassle you will learn how to import content into Drupal using the Feeds module. You’ll then get a brief introduction to the Migrate module and its powerful features.

With this guide you’ll also learn how to upgrade your Drupal 6 website to Drupal 7 in short, simple steps. You’ll also learn how to package your configuration code in Drupal using the powerful Features module.

In "Migrating to Drupal 7" you’ll start by collecting your current site’s content and packaging it up into a CSV file so you can easily import it into Drupal. You’ll then build a content type to hold your migrated data and content.

Mastering migrations using the Feeds module will be the next invaluable tutorial before you get a closer look at the Migrate module’s powerful features. You’ll then upgrade your Drupal 6 site to Drupal 7 and use helper modules to help run the upgrade faster and with less hassle. This book will then take you through the process of migrating CCK-based Drupal 6 fields to Drupal 7 using the Content Migrate module.

Using the Features module you will then package up our Feeds importer and content types into code to help you to build an easily maintainable and flexible Drupal website with.

Approach

Written in a friendly and engaging style with practical tutorials and step-by-step examples which show you how to easily migrate your Drupal 6 or WordPress site to Drupal 7.

Who this book is for

"Migrating to Drupal 7" is for anyone interested in how to move content from an existing website into the Drupal content management system. Both novice and advanced Drupal users will gain practical hands-on knowledge in how to migrate content into Drupal using this book. You will become experts in using the Feeds module to migrate content, and in packaging your code using Features.

Organic Groups (OG) Migration from Earlier Versions

Database Issues

If your database has a hyphen(-) in it, please make sure #1926418: OG Migrate fails if database name contains hyphen is resolved before reporting any new issues.

Setup

In order to upgrade Organic Groups from Drupal 6 or from OG 7.x-1.x to 7.x-2.x, the following modules must be installed and enabled:

Execution

Once the required modules have been enabled

  1. Make a backup of both your files and database.
  2. Download the latest version of OG 7.x-2.x (this can done via drush or ftp).
  3. Run update.php. If you're unsure what this means, go to the following URL and follow the instructions:
    http://yoursite.com/update.php
    After running the update script, you may get the message "The content access permissions need to be rebuilt. Rebuild permissions." Wait to rebuild permissions until after running the migrate scripts.
  4. Navigate to:
    http://yoursite.com/admin/content/migrate
  5. You should see the migrates that are still pending:

Migration and group registration

Migrations and migration groups

For the migration classes you implement to be available for reviewing status, running imports, etc., instances of them must be registered. There are two methods of getting your migrations and migration groups registered:

hook_migrate_api()

This is the recommended means of registering your migrations and migration groups if they're static - that is, if you don't need to pick-and-choose at runtime what migrations to register or what arguments to set for them.

It's recommended that you explicitly assign your migrations to a migration group (if you don't, they will be in the 'default' group). Groups can be registered in the API array by including a 'groups' key, whose value is an array keyed by the group machine name and the value an array of arguments for the group. The 'title' argument is special - this is the name of the group as it will be presented in the UI (if you omit the title, the machine name will be displayed instead). Any other arguments are saved as part of the group, and made available to any migrations in the group when they are instantiated.

The 'migrations' key should be an array, keyed by the migration machine name, with the value an array of arguments. 'class_name' is the one required argument (although 'group_name' is recommended) - any others are class-specific arguments.
<?php

Taxonomy term migration

In migrating taxonomy terms, the key is mapping the legacy vocabulary to the destination vocabulary. Note that up till now we've dealt with classes that you will generally instantiate once - this is our first example of classes you would instantiate multiple times, one for each vocabulary to migrate.

  • source_vocabulary: The unique identifier of the legacy vocabulary (a machine name in Drupal 7, or a vid for earlier Drupal versions).
  • destination_vocabulary: The unique machine name of the destination vocabulary.

<?php
// In this example, we're consolidating two legacy vocabularies into one
$photo_term_arguments = $common_arguments + array(
'machine_name' => 'ExamplePhotoTerm',
'description' => t('Import Drupal 6 photo terms into media terms'),
'source_vocabulary' => '3', // "Photo category" vocabulary
'destination_vocabulary' => 'media_category',
);
Migration::registerMigration('DrupalTerm6Migration',
$photo_term_arguments['machine_name'], $photo_term_arguments);

$video_term_arguments = $common_arguments + array(
'machine_name' => 'ExampleVideoTerm',
'description' => t('Import Drupal 6 video terms into media terms'),
'source_vocabulary' => '5', // "Video category" vocabulary
'destination_vocabulary' => 'media_category',
);

Adding serialized data to users data column

The users table has a "data" column which can store serialized data, but you cannot migrate into this field by doing a mapping, because the user migration doesn't provide the "data" field as a possible mapping destination.

Instead, you can add the serialized data in your migration by implementing the prepare() method, which operates on the created entity:

Pages

Subscribe with RSS Subscribe to RSS - migrate