Drupal 6 to Drupal 7 migration redirect not working I am migrating a D6 site to D7 and for some odd reason the redirect module is not creating the redirections. Any ideas? I am not getting any errors, warnings or notices

This is what I have:

class MyNewsMigration extends MyNodeMigration {
  public function __construct(array $arguments) {

    parent::__construct($arguments);

    $this-&gt;addFieldMapping('field_tag', '8')
         -&gt;sourceMigration('Tag');
    $this-&gt;addFieldMapping('field_tag:source_type')-&gt;defaultValue('tid');
    $this-&gt;addFieldMapping('field_tag:create_term')-&gt;defaultValue(FALSE);
    $this-&gt;addFieldMapping('field_tag:ignore_case')-&gt;defaultValue(TRUE);

    // Redirect module to issue a 301 for each changing path
    $this-&gt;addFieldMapping('pathauto')-&gt;defaultValue(1);
    $this-&gt;addFieldMapping('migrate_redirects', 'path');

  }
}


Note: I added the migrate.redirect.inc using patch from here https://www.drupal.org/node/1116408
I had a slightly different use case - changing aliases for users from /source/user-name to /author/user-name and creating redirects from the old alias the new one - but the steps are still the same.

First, I implemented a complete() method in my migrate class. This is called after the new entity (node, user, etc) has been created:

  /**
   * Implementation of MigrateDestinationEntity::complete() method.
   *
   * @param $entity
   * @param $row
   */
  function complete($account, $row) {
    // Create redirect from old Source alias that uses /source/
    // to new user profile alias.

    if (!redirect_load_by_source($row-&gt;dst)) {
      // First, get the alias for the user profile. We have to generate it separately
      // here because pathauto_create_alias() has already been run by the time the code
      // gets here, and we don't have access to that path.
      $new_alias = pathauto_create_alias('user', 'return', 'user/' . $account-&gt;uid, array('user' =&gt; $account));

      // Next, create the $redirect object and save it.
      $redirect = new stdClass();

      redirect_object_prepare(
        $redirect,
        array(
          'source' =&gt; $row-&gt;dst,
          'source_options' =&gt; array(),
          'redirect' =&gt; $new_alias,
          'redirect_options' =&gt; array(),
          'language' =&gt; LANGUAGE_NONE,
        )
      );
      redirect_save($redirect);
    }
  }


And then, to handle rollbacks (during development), I created a new class that overrides DrupalDestinationUser and implements a custom prepareRollback method:

class CNSUserDestination extends DrupalDestinationUser {
  // Add prepareRollback() method to this class.
  public function prepareRollback($uids) {
    parent::prepareRollback($uids);
    // Load all of the entities, since we need them for pathauto_create_alias().
    $users = entity_load('user', $uids);

    // Load pathauto.inc file.
    module_load_include('inc', 'pathauto', 'pathauto');

    foreach ($users as $uid =&gt; $user) {
      $redirects[] = pathauto_create_alias('user', 'return', 'user/' . $user-&gt;uid, array('user' =&gt; $user));
    }

    // Delete redirects for user profiles.
    db_delete('redirect')
      -&gt;condition('redirect', $redirects)
      -&gt;execute();
  }
}


It worked like a charm.