map = new MigrateSQLMap( $this->machineName, array( 'boardid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, ), ), MigrateDestinationTerm::getKeySchema() ); $query = Database::getConnection('default', 'forum') ->select('wbb1_1_board', 'b') ->fields('b', array( 'boardid', 'parentid', 'title', 'description', 'allowdescriptionhtml', 'boardtype', 'image', 'externalurl', 'time', 'prefixes', 'prefixrequired', 'styleid', 'enforcestyle', 'daysprune', 'sortfield', 'sortorder', 'isclosed', 'countuserposts', 'isinvisible', 'showsubboards', 'clicks', 'threads', 'posts', )) ->orderBy('parentid', 'ASC'); $query ->leftJoin('wbb1_1_board_structure', 's', 'b.boardid = s.boardid'); $query ->fields('s', array( 'position', )); $this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE)); $this->destination = new MigrateDestinationTerm('forums'); $this->addFieldMapping('name', 'title'); $this->addFieldMapping('description', 'description'); $this->addFieldMapping('parent', 'parentid') ->sourceMigration($this->machineName); $this->addFieldMapping('parent_name'); $this->addFieldMapping('weight', 'position'); } public function complete($entity, stdClass $row) { if (!$entity->parent || !$entity->parent[0]) { $containers = variable_get('forum_containers', array()); if (!in_array($entity->tid, $containers)) { $containers[] = $entity->tid; variable_set('forum_containers', $containers); } } } }