Last updated February 6, 2012. Created by StuartDH on February 6, 2012.
Log in to edit this page.
Some of my vBulletin site's threads and posts have tags that I'd liked to migrate to Drupal. vBulletin stores this data in the 'tag' table, and so before migrating threads and posts I'm going to migrate the data to D7's 'tag' vocabulary.
It should be all fairly simple and self-explanatory in the following class code:
<?php
class vBulletinTagMigration extends Migration {
public function __construct() {
parent::__construct();
$this->description = t('Migrate vBulletin forum tags');
// Set the source table's primary key, which is the 'tagid' field
$this->map = new MigrateSQLMap(
$this->machineName,
array(
'tagid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'vBulletin forum tags',
'alias' => 'g',
),
),
MigrateDestinationTerm::getKeySchema(),
'for_forum_migration'
);
// Set the query to get source data from the vBulletin tag table
$query = Database::getConnection('default', 'for_forum_migration')
->select('tag', 'g')
->fields('g', array(
'tagid',
'tagtext',
'dateline',
));
// This sort ensures that parents are saved before children.
$this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE));
// Define the destination as terms in the tags vocabulary
$this->destination = new MigrateDestinationTerm('tags');
// Map fields that you want in the D7 forum from vBulletin
$this->addFieldMapping('name', 'tagtext')
->description('vBulletin tag to D7 term name');
// Unmapped destination fields
$this->addFieldMapping('description') ->description(t('vBulletin tags do not include a description'))
->issueGroup(t('DNM'));
$this->addFieldMapping('format') ->description(t('vBulletin tags do not have a format'))
->issueGroup(t('DNM'));
$this->addFieldMapping('weight') ->description(t('vBulletin tags do not have a weight'))
->issueGroup(t('DNM'));
$this->addFieldMapping('parent_name') ->description(t('vBulletin tags do not have a parent_name'))
->issueGroup(t('DNM'));
$this->addFieldMapping('parent') ->description(t('vBulletin tags do not have a parent'))
->issueGroup(t('DNM'));
// Unmapped source fields
$this->addFieldMapping(NULL, 'dateline') ->description(t('Date when tag created is not needed'))
->issueGroup(t('DNM'));
}
}
?>