5

I'm using migrate module in Drupal 7 to update existing content of a Drupal site. My source and destination tables are the same. I got some documentation from http://drupal.org/node/1117454. Here's my code:

<?php
class MTestMigration extends Migration {

  public function __construct() {
    parent::__construct();
    $this->systemOfRecord = Migration::DESTINATION;
    $this->team = array(
      new MigrateTeamMember('foo', 'foo@bar.com', t('Site builder')),
    );

    $this->description = t('Migrate basic slides');

    $source_fields = array(
      'nid' => t('The node ID of the slide'),
      'title' => t('The node title of the slide'),
      'uri' => t('the slide image'),
    );

    $q = db_select('node', 'n');
    $q->leftjoin('field_data_field_image', 'i', 'i.entity_id=n.nid');
    $q->leftjoin('file_managed', 'f', 'i.field_image_fid=f.fid');
    $q->fields('n', array('nid', 'vid', 'type', 'language', 'title', 'uid', 'status', 'created', 'changed', 'comment', 'promote', 'sticky', 'tnid', 'translate'))
      ->fields('f', array('uri'))
      ->condition('n.type', 'slide', '=');
    $this->source = new MigrateSourceSQL($q, $source_fields);


    $node_options = MigrateDestinationNode::options(LANGUAGE_NONE, 'filtered_html');
    $this->destination = new MigrateDestinationNode('slide', $node_options);

    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'nid' => array(
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'description' => 'Unique Node ID',
            'alias' => 'n',
          )
        ),
        MigrateDestinationNode::getKeySchema()
    );

    $this->addFieldMapping('is_new')
      ->defaultValue(TRUE);

    $this->addFieldMapping('nid', 'nid');
    $this->addFieldMapping('title', 'title');
    $this->addFieldMapping('is_new')->defaultValue(TRUE);
    $this->addFieldMapping('uid', 'uid');
    $this->addFieldMapping('revision')->defaultValue(TRUE);
    $this->addFieldMapping('revision_uid', 'uid');
    $this->addFieldMapping('created', 'created');
    $this->addFieldMapping('changed', 'changed');
    $this->addFieldMapping('status', 'status');
    $this->addFieldMapping('promote', 'promote');
    $this->addFieldMapping('sticky', 'sticky');
    $this->addFieldMapping('comment', 'comment');
    $this->addFieldMapping('language')->defaultValue('und');

    $this->addFieldMapping('path')->issueGroup(t('DNM'));
    $this->addFieldMapping('pathauto_perform_alias')->defaultValue('1');

    $this->addFieldMapping(NULL, 'name');
    $this->addFieldMapping(NULL, 'vid');
    $this->addFieldMapping(NULL, 'type');
    $this->addFieldMapping(NULL, 'language');
    $this->addFieldMapping(NULL, 'tnid');
    $this->addFieldMapping(NULL, 'translate');

    $this->addFieldMapping('field_image', 'uri')
      ->arguments(FILE_EXISTS_RENAME);
  }
}

I end up with this error:

Column not found: 1054 Unknown column 'map.destid1' in 'field list': SELECT n.nid AS nid, n.vid AS vid, n.type AS type, n.language AS language, n.title AS title, n.uid AS uid, n.status AS status, n.created AS created, n.changed AS changed, n.comment AS comment, n.promote AS promote, n.sticky AS sticky, n.tnid AS tnid, n.translate AS translate, f.uri AS uri, map.destid1 AS migrate_map_destid1, map.needs_update AS needs_update FROM {node} n LEFT OUTER JOIN {field_data_field_image} i ON i.entity_id=n.nid LEFT OUTER JOIN {file_managed} f ON i.field_image_fid=f.fid LEFT OUTER JOIN {migrate_map_mtest} map ON n.nid = map.sourceid1 WHERE (n.type = :db_condition_placeholder_0) AND (map.sourceid1 IS NULL OR map.needs_update = 1) ; Array ( [:db_condition_placeholder_0] => slide ) in MigrateSourceSQL->rewind()

  • Did you clear caches before you ran? Have you changed the destination or the key at all? Is Migrate the best option for this? – Christian Aug 21 '12 at 9:30
3

This post about Unknown column 'destid1' in 'field list' helped me when I had the same problem.

In particular, drop the migrate_map_* and migrate_message_* tables since they may have been created incorrectly beforehand.

  • Also if you want to do Updates to content in Migrate > 2.5 (for example Migrate 2.6) you can supply $options['track_changes'] = TRUE; for any MigrateSource class. More about that here: timonweb.com/… – tenken Jan 16 '14 at 16:05
  • The link in the previous comment moved to timonweb.com/posts/… – htoip Dec 13 '17 at 20:29

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .