Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Node migrations are much like term migrations, in terms of mapping a source type to a destination type.
- source_type: The unique machine name of the legacy node type.
- destination_type: The unique machine name of the destination node type.
- user_migration: The machine name of your user migration, used to properly assign authorship of the nodes.
- default_uid: A default destination uid to use as the default author of nodes where a legacy owner isn't identified (for example, nodes authored by the account with uid 1 in the legacy system, since that account is not migrated).
- default_language: Default language for the node and the node body. Defaults to LANGUAGE_NONE.
// Use another layer of common arguments to reduce duplication
$node_arguments = $common_arguments + array(
'user_migration' => 'ExampleUser',
'default_uid' => 1,
);
$photo_node_arguments = $node_arguments + array(
'machine_name' => 'ExamplePhotoNode',
'description' => t('Import Drupal 6 photo nodes'),
'source_type' => 'photo',
'destination_type' => 'photo',
'dependencies' => array('ExamplePhotoTerm'),
);
// Note we use a custom class here so we can map the term references and
// other fields - see "Extending migrate_d2d classes" below.
Migration::registerMigration('ExamplePhotoNodeMigration',
$photo_node_arguments['machine_name'], $photo_node_arguments);
$video_node_arguments = $node_arguments + array(
'machine_name' => 'ExampleVideoNode',
'description' => t('Import Drupal 6 video nodes'),
'source_type' => 'video',
'destination_type' => 'video',
'dependencies' => array('ExampleVideoTerm'),
);
// Note we use a custom class here so we can map the term references and
// other fields - see "Extending migrate_d2d classes" below.
Migration::registerMigration('ExampleVideoNodeMigration',
$video_node_arguments['machine_name'], $video_node_arguments);
Comments
Extending migrate_d2d classes
The section mentioned in the code comments "Extending migrate_d2d classes", doesn't actually exist in the documentation... there's an example module that ships with migrate_d2d though that can help out with writing Node migrations.
Link
Extending migrate_d2d classes
migrate_d2d does not create currently content types at destinati
Just wanted to add that according to #1885914: Create content types/fields, migrate_d2d does *not* current provide the ability to create Content Types at the destination.
--
http://drupaltees.com
80s themed Drupal T-Shirts
Preserve NID?!
I've been searching for this answer for weeks. Will this module keep the same Node IDs when I migrate the content?
The node migration provided
The node migration provided in migrate_d2d does not maintain node ids in the destination. The underlying migrate module does, however, provide the means to reflect new node ids in other references by means of mapping references to node ids (or any primary id, for that matter) in dependent migrations. So, for example, you might migrate your files, which will result in new fid identifiers. Image fields which refer to that may be mapped using the sourceMigration('YourSourceMigrationName') chained method, such as:
If it is essential to maintain node (and even vids), you are going to code this yourself. It might be easy -- I'm not sure. I would look at mapping the nid field as a first start.
Thanks for your response
Thanks for your response
In D7 you can use the 'is_new' field to preserve NID
You can add a field mapping to NID if you also set the
is_new
field toTRUE
. So just addto your usual migration_d2d code.
Using the d2d UI to preserve migrated NID or UID
see https://www.drupal.org/node/2287757#comment-9569597 for how to use the d2d ui to preserve migrated nid/uid
Content Type
I'm migrating from D6 to D7. My D6 has 28 content types... should I create these content types in D7 before migrating?
Thanks,
Yes
Yes, you'll need to create your new content types and fields in Drupal 7 before being able to do the migration.
Only images/files associated with nodes
I want to migrate only images & files associated with nodes. Not all files & images, so I am thinking the "Source Migration" way may not work. How do I achieve this?