I am migrating a Drupal 7 site to an updated Drupal 7 site. The nodes and taxonomies on the old site were handled in custom tables.
I have migrated 2,000 nodes and that worked fine. My taxonomy terms have also been imported. I now have a custom table of 87,000 instances of terms being applied to the nodes over seven different term reference and entity reference fields.
When I try to run the term migration I get the error: System-of-record is DESTINATION, but no destination nid provided. I have seen this error elsewhere but have not solved my problem by looking at these other issues.
This is my node migration:
class MyNodeWebMigration extends MyMigration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Web Reports v2');
$query = Database::getConnection('default', 'datasource')
->select('my_data_group', 'sdg');
$query->fields('sdg', array('groupid', 'name', 'description', 'notes', 'grp_level',
'level1', 'level2', 'submitted', 'published', 'approver_notes', 'preprocessed',
'themeid', 'public_health_significance', 'target_event', 'talking_points',
'report_type', 'nid'));
$count_query = Database::getConnection('default', 'datasource')
->select('my_data_group', 'sdg');
$count_query->addExpression('COUNT(groupid)', 'cnt');
$this->source = new MigrateSourceSQL($query, array(), NULL,
array('map_joinable' => FALSE));
// Set up our destination - nodes of type web_ready
$this->destination = new MigrateDestinationNode('web_ready');
$this->map = new MigrateSQLMap($this->machineName,
array(
'groupid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'Report Group ID.',
'alias' => 'sdg',
)
),
MigrateDestinationNode::getKeySchema()
);
// Mapped fields
$this->addFieldMapping('title', 'name')
->description(t('Mapping Report name in source to node title'));
$this->addFieldMapping('status', 'published');
$this->addFieldMapping('field_group_id', 'groupid');
$this->addFieldMapping('body', 'description');
}
}
This is the second migration I am using to import the terms into the fields on my nodes:
class MyReportTypeTermToWebMigration extends CMyMigration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Imports Report Type Terms Into Web Reports');
$query = Database::getConnection('default', 'datasource')
->select('my_data_meta', 'sdm');
$query->fields('sdm', array('groupid', 'vocab', 'tid'))
->condition('vocab', 'report_doc_type');
$count_query = Database::getConnection('default', 'datasource')
->select('my_data_meta', 'sdm');
$count_query->addExpression('COUNT(groupid)', 'cnt');
$this->source = new MigrateSourceSQL($query, array(), NULL,
array('map_joinable' => FALSE));
$this->systemOfRecord = Migration::DESTINATION;
// Set up our destination - nodes of type web_ready
$this->destination = new MigrateDestinationNode('web_ready');
$this->map = new MigrateSQLMap($this->machineName,
array(
'groupid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'Report Group ID.',
'alias' => 'sdg',
)
),
MigrateDestinationNode::getKeySchema()
);
// Mapped fields
$this->addFieldMapping('nid', 'groupID')
->sourceMigration('CBHSQNodeWebReady');
$this->addFieldMapping('field_report_doc_type', 'tid')
->separator(',')
// Note this is the machine name of the user migration.
->sourceMigration('CBHSQTermReportDocType');
}
}
When I run this second migration I get the error in the title of this issue. Any help would be greatly appreciated.
Comments
Comment #2
gettysburger commentedhttps://www.drupal.org/node/1117454
This issue might have a clue about using destid1 in the prepareRow() function.
Comment #3
gettysburger commentedI made some progress. I added this:
...and now at least I get a different error:
...which means I simply need to figure out a way to map the source groupid to the nid using the MyNodeWebReady migration class.
Does that sound correct?
Comment #4
gettysburger commentedSolved it! Here is the solution. I used a query to explicitly associate the source data with the target node.
Comment #5
gettysburger commented