In order to upgrade your site from Drupal 6 to Drupal 7, the content of your D6 site must be migrated to your new D7 site. We will be using the following modules to migrate data by content type:
- Views Data Export
- Feeds Import
- Feeds Tamper
Create D7 Content Structure
Before you begin, it is advised that you first determine how you want to organize and structure the new D7 site. There may be certain fields and information that you’d rather leave behind moving forward. Additionally, there may be new fields you’d like to implement.
One suggestion is to create a document that clearly defines all of your content types and their respective fields. This will make the migration process much simpler.
Once you’ve decided on your content types and how the content will be structured, create your content types manually on the new D7 site. Add every field you plan on migrating from D6. Don’t worry about the machine names – they can be different from D6! Use this opportunity to clean up your machine names if you feel it necessary.
- In D7, go to Structure > Content Types > + Add content type
- Enter information and click “Save and add fields”
- Add the appropriate fields for this content type (reference your excel spreadsheet created earlier)
- Save and repeat for each content type
After you’ve created all of the content types and added all the desired fields on the new D7 site, you can begin the migration process.
Apply Patch and Create Export Views
First, apply the views_data_export_D6 patch to your D6 site. This patch will maintain the HTML and formatting of your D6 content by inserting a “Keep HTML tags” option. Without it, you will lose all of your HTML tags.
- Patch can be found at https://arizona.box.com/s/zve58erv39k72f5p2jb2j5rbfx3bpc2k
- For more detailed information on how to apply patches in D6, go to https://www.drupal.org/patch/apply
Custom Export Date Type
After the patch has been applied, create a custom date format in your D6 site that follows this format exactly: Mon, 2012-09-15 18:30. Title this date format “Export Type” (or something along those lines).
- Site configuration > Date and Time > Formats > Add format
- Format string: D, Y-m-d H:I (determined from PHP manual)
- Save configuration
- Go to Date and Time > Formats > Configure and scroll to bottom of page
- Add format type by including Name (human-readable name) and Type (machine-readable name), then Save configuration
- In list of date formats, go to your newly created format type and select the correct date format from the dropdown list (e.g. Mon, 2012-09-15 18:30) and save again
Create Export Views
Next, go to your D6 Views page (Site building > Views > List). Create a new view of the first content type you’d like to migrate. The name and path should end in “export” (e.g. basic_page_export) with View type as Node.
Once created, add a “Data export” display.
In this display, add Node: Type filter of the content type you’re migrating.
If you do not want to migrate ALL of your content, you can add an optional date filter to migrate only content created after 2012, for example. This is most useful for news/events content types.
Next, add fields you’d like to migrate for this content type (consult the excel spreadsheet and/or D7 content types you made earlier).
If your content type has a date field, click it and select the custom date format you created earlier (e.g. Export Type). Otherwise, the date field won’t migrate correctly.
If your content type has an image or file/attachment field, click that field and check the Link this field to download the file and Only show "listed" file attachments options at the bottom if not checked already.
Under Basic settings, select “CSV file” for Style. Click the settings link to check the “Keep HTML tags” option (if you don’t see this option, that means the patch wasn’t installed properly).
Update to save your changes.
Data Export Settings
Last, add a path to the view. Using the view’s title is recommended for the path.
Update and save the view. Once saved, go to the URL path and the CSV file of your data for this particular content type will be downloaded locally.
Edit the CSV
Using a text editor (such as Text Wrangler), open the CSV file. Do not edit the CSV in Excel! Only view in Excel. Special characters will be lost if the file is edited there.
To migrate the “Published” field from D6 to D7, the values must be 1 and 0 instead of Yes or No. So, in the CSV file, replace all these values where “Yes”=1 and “No”=0.
If your content type has an image field, you will see that those values include html tags around the image URL. These tags must be removed leaving only the URL. Find and replace tags using patterns specific to the tags with grep or a regular expression. All that should remain is the full URL.
Once these changes have been made, go ahead and save.
Import D6 Content into D7
Before moving the content into D7, make sure the following modules are installed and active on your D7 site:
- Feeds Import
- Feeds Tamper
Next, in your D7 site, go to Structure > Feeds importers. You will add an importer for each separate content type.
- + Add importer and enter name of content type import (e.g. basic page import, event import) and optional description
- Under Basic Settings, turn Periodic import to off
- Change Fetcher to File upload
- Change Parser to CSV parser
- Change Processer to Node processer
- Under Node processer Settings, from the Bundle dropdown select the D7 content type that matches the D6 content that you are migrating. Change the Text Format to Full HTML. Change the author to yourself (to help keep track of the content you imported).
- Under Node processer Mapping, match the D6 source with its corresponding D7 target.
- Copy and paste the field name from your CSV file into the text box under Source.
- Map this field to a D7 field in the dropdown under Target.
- Change the Text Format to Full HTML.
- Save your changes
Once saved, navigate to the Tamper tab on the top right. If your content has a date field, add plugin: String to Unix timestamp. Save.
Last, navigate to your D7 site with the path “/import” and select the import you just created. Upload the CSV file and click Import.
Repeat this process for each content type you’d like to migrate.
You have just successfully migrated your D6 content into your new D7 site.
Note: If you find errors in the migration, go back to your import and navigate to the Delete Items tab. This will delete all the content that was imported in this migration so you can try again.