Download & Extend

Field Mappings Documentation Help

Project:Migrate
Version:7.x-2.2
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

Hi,

I've been using Drupal 5/6 & 7 for a few years on several small sites, but now need to look at migrating a site into Drupal 7 that currently has 50,000 members, nearly a million posts in a vBulletin forum, two Photopost galleries with 200,000 images, and 20,000 Drupal 6 nodes across twenty different content types...so I thought it time that I learn something about the migrate module :)

I'm basically new to the migrate process, with virtually no code experience, so I've started to gather as much info as I can, and whilst doing it I thought I'd try and add to migrate v2's documentation.

I'm gathering info from beer.inc, wine.inc, external references and these issue pages etc to create document pages about each of the key aspects of the migrate code, such as field mappings, sources classes etc. This will hopefully enable users to walk through steps on just a single subject that get progressively more detailed and show examples of how the features can be used.

Rather than asking the community to read and re-read the above content as it changes, I hope it's OK if I flag up any problems that I come across in this issue. I'll add each one as a new top-level reply to try and run threads for each example

Thanks

Stuart

Comments

#1

Title:Field Mappings Documentation Help» More Dedupe info

Top level

#2

Line 197 in beer.inc, with the example for Default where empty or NULL, is a bit confusing

<?php
   
// Instead of mapping a source field to a destination field, you can
    // hardcode a default value. You can also use both together - if a default
    // value is provided in addition to a source field, the default value will
    // be applied to any rows where the source field is empty or NULL.
   
$this->addFieldMapping('roles')
         ->
defaultValue(2);
   
$this->addFieldMapping('field_migrate_example_gender', 'sex');
?>

I can't tell where the source data field for the roles is specified, and the gender field look as though it doen't belong here.

Does anyone have another example we could use?

#3

I don't really understand the current Dedupe info in line 185 in beer.inc and I think the some of confusion comes from having 'name' three times in the code

<?php
   
// Dedupe assures that value is unique. Use it when source data is non-unique.
    // Pass the Drupal table and column for determining uniqueness.
   
$this->addFieldMapping('name', 'name')
         ->
dedupe('users', 'name');
?>

I've not used dedupe yet, but would the following make more sense...i.e. does the dedeupe refer to the destination field 'name', or should it be 'username'?

<?php
   
// Dedupe assures that value is unique. Use it when source data is non-unique.
    // Pass the Drupal table and column for determining uniqueness.
   
$this->addFieldMapping('name', 'username')
         ->
dedupe('users', 'name');
?>

Would it be possible for someone to write a quick note about what's happening in the dedupe code or does anyone have another explanation and example that we could add to the documentation?

Stuart

#4

Title:More Dedupe info» Field Mappings Documentation Help
Assigned to:Anonymous» StuartDH

#5

Recently I have been using Migrate to move users, articles, and taxonomy from a D6 site into D7. Many field mappings are obvious: article has a "name" and a "body" which are clearly linked from similarly named fields in D6.

When moving taxonomy, I was in the dark on how to override the destination vocabulary. A vocabulary is necessary in the instantiation of MigrateDestinationTerm objects. mikeryan helped me out in understanding what needs to be done here:
http://drupal.org/node/1463356

Having been pointed in the right direction I can now see that, using the Devel module (http://drupal.org/project/devel), 'vocabulary_machine_name' is indeed a field for taxonomy terms. This was not obvious to me until I knew what to look for...

I was also unclear on how to get teasers out of D6 into D7 "body_summary". I asked about this and received this response:
http://drupal.org/node/1461714

But this is very obscure to me. Although an example of this is given in beer.inc, it seems to me that some decisions about where to insert data into the D7 database are happening automagically. Looking at the Devel output for an Article which was successfully migrated with its body summary in this fashion, I am not seeing an optional argument to the "body" field which would give any indication that a summary may be provided during migration. (How does a "body" argument of "excerpt" in beer.inc or "teaser" in my case end up in "body_summary"?)

Is there a comprehensive list of what fields and field arguments are available for mapping using the addFieldMapping() function, other than obvious ones like "name" and "description" and "weight"?

#6

For instance the API for MigrateDestinationTerm::fields() is here:

http://drupalcontrib.org/api/drupal/contributions!migrate!plugins!destinations!term.inc/function/MigrateDestinationTerm%3A%3Afields/7

But this does not tell you that 'vocabulary_machine_name' is available for mapping.

#7

Assigned to:StuartDH» Anonymous
Status:active» closed (duplicate)

The "Example Field Mappings" documentation page was largely just a rewording of the main mappings page, I've incorporated some of the thoughts there into the main page and unpublished that one - it's better to suggest changes to the documentation than to fork it.

I'm planning on building out more detailed documentation on specific field mappings in #1528916: Flesh out docs on destination fields, and link to them, closing this in favor of that.

nobody click here