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

mikeryan’s picture

Status: Active » Fixed

This:

->getSourceMigration($this->machineName);

should be this:

->sourceMigration($this->machineName);
pixlkat’s picture

Thank 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.