Closed (fixed)
Project:
Migrate
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 May 2012 at 22:40 UTC
Updated:
31 May 2012 at 14:20 UTC
I am attempting to migrate some data from an old database into drupal and started with the taxonomy migration. No matter what I do, the parent in taxonomy_term_hierarchy is the parent id that is in the source table. I am creating my map table in the source database, and they are mapped correctly there. If I run the migration a second time with --update, nothing changes.
I found a couple of closed issues, but any resolution suggested in them has worked for me.
Using drupal 7.14, and I have tried both with 7.x-2.3 and 7.x-2.x-dev downloaded today.
Here's my code:
class PolicyTermMigration extends Migration
{
public function __construct($group = NULL)
{
parent::__construct($group);
$this->description = t('Migrate policy categories from legacy database');
// map table
$this->map = new MigrateSQLMap($this->machineName,
array('id' => array(
'type' => 'int',
'not null' => TRUE
)),
MigrateDestinationTerm::getKeySchema(),
'policy_legacy');
// source
$query = Database::getConnection('default', 'policy_legacy')
->select('policy_category', 'c')
->fields('c', array('id', 'title', 'pid', 'column_locked', 'description', 'display_url'))
->orderBy('pid', 'ASC');
$this->source = new MigrateSourceSQL($query);
// destination
$this->destination = new MigrateDestinationTerm('policy');
// field mappings
$this->addFieldMapping('name', 'title');
$this->addFieldMapping('description', 'description');
$this->addFieldMapping('parent', 'pid')
->arguments(array('source_type' => 'tid'))
->getSourceMigration($this->machineName);
$this->addUnmigratedSources(array('column_locked', 'display_url'));
$this->addFieldMapping('pathauto')->defaultValue(0);
// Unmapped destination fields
$this->addFieldMapping('parent_name')
->issueGroup(t('DNM'));
}
function prepareRow($row)
{
if ($row->pid==0)
{
$row->pid = NULL;
}
}
}
What am I missing?
Comments
Comment #1
mikeryanThis:
should be this:
Comment #2
pixlkat commentedThank you so much! I stared at that until I thought my eyes were going to fall out of my head and I totally missed that.