You are here

public function ShortURLMigration::__construct in ShURLy 7

General initialization of a Migration object.

Overrides CommonMigration::__construct

File

shurly_migration/shurly_migration.migrate.inc, line 25

Class

ShortURLMigration
Class ShortURLMigration migrates from Shurly Drupal 6 module

Code

public function __construct($arguments) {
  parent::__construct($arguments);
  $this->description = 'Short URLs to Shurly Migration';
  $table_name = 'shurly';
  $query = db_select('shorturl_link', 't')
    ->fields('t', array(
    'lid',
    'orig_url',
    'created',
  ));
  $this->source = new MigrateSourceSQL($query);
  $this->destination = new MigrateDestinationTable($table_name);
  $this->map = new MigrateSQLMap($this->machineName, array(
    'lid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
  ), MigrateDestinationTable::getKeySchema($table_name));

  // Mapped fields
  $this
    ->addFieldMapping('source', 'lid')
    ->callbacks(array(
    $this,
    'shortUrlDecode',
  ))
    ->defaultValue('unprocessed');
  $this
    ->addFieldMapping('destination', 'orig_url');
  $this
    ->addFieldMapping('created', 'created');
  $this
    ->addFieldMapping('last_used')
    ->defaultValue(0);
  $this
    ->addFieldMapping('count')
    ->defaultValue(0);
  $this
    ->addFieldMapping('custom')
    ->defaultValue(0);
  $this
    ->addFieldMapping('uid')
    ->defaultValue(1);
  $this
    ->addFieldMapping('active')
    ->defaultValue(1);
  $this
    ->addUnmigratedDestinations(array(
    'rid',
  ));
}