Quantcast
Channel: Migration taking increasingly long periods of time - Drupal Answers
Viewing all articles
Browse latest Browse all 2

Migration taking increasingly long periods of time

$
0
0

I have a migration and I've noticed that the code, through each batch operation, seems to process less and less items.

For example, the first few cycles, it'll say, "processed 600", and 600 or around there will be processed. However about 5-10 cycles in, and it will still say "processed 600", and it actually processes perhaps 100 or 200. This eventually stops the migration from happening, as it essentially grinds to a halt.

It was completing on my local machine and not the stage environment, which I initially thought to be due to some sort of environmental condition. Now I think that the cycles on my local were just large enough to allow everything to process before it grinded to a halt.

I'm not sure what is causing this, and if it's in this migration, or the migration that this migration is extending. I'll include the former, and if anyone needs the latter, let me know.

Note, there may be occasional instances where the words Company or Type are capitalized when they should not be - I just did a quick find/replace for sensitive data.

class CompanyTypeUserDataMigration extends CompanyCertBaseMigration {public function __construct($arguments) {    parent::__construct($arguments);    $this->machineName = "CompanyTypeUserData";    $this->systemOfRecord = Migration::DESTINATION;    $this->group = MigrateGroup::getInstance("Company");    $query = Database::getConnection('default', 'Type')        ->select('Type')        ->fields('Type', array('Name', 'Username', 'Address', 'City', 'State', 'Zipcode', 'Country', 'Phone', 'Notes', 'Email'));    $query->addExpression('`Company Name`', 'Company');    $query->addExpression('`Supervisor Email`', "supervisor_email");    $query->addExpression('`Declined Recert Renewal`', "declined_recert");    $query->isNotNull('Username');    $this->source = new MigrateSourceSQL($query, array('status' => 'Status calculated based on various fields'));    $this->destination = new MigrateDestinationUser();    $this->map = new MigrateSQLMap($this->machineName, array('Username' => array('type' => 'varchar','length' => 50,'unsigned' => FALSE,'not null' => FALSE,            ),'Email' => array('type' => 'varchar','length' => 50,'not null' => FALSE,            )        ), MigrateDestinationUser::getKeySchema()    );    $this->addFieldMapping('name', 'Username');    $this->addFieldMapping('field_company', 'Company');    $this->addFieldMapping('field_supervisor_email', 'supervisor_email');    $this->addFieldMapping('field_notes', 'Notes');    $this->addFieldMapping('field_status', 'status');    $this->addFieldMapping('field_full_name', 'Name');    $this->addFieldMapping('uid', 'user_id');}public function prepareRow($row) {    // Always include this fragment at the beginning of every prepareRow()    // implementation, so parent classes can ignore rows.    if (parent::prepareRow($row) === FALSE) {        return FALSE;    }    if (empty($row->Username)) {        return FALSE;    }    $uid = $this->find_user_id($row);    if($uid === FALSE){        return false;    } else {        $row->user_id = $uid;        $user = user_load($uid);        if(isset($user->name)){            $row->Username = $user->name; //so we don't try to overwrite username permutations        }    }}}

Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>