Update existing content using migrate module 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:

&lt;?php
class MTestMigration extends Migration {

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

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

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

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


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

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

    $this-&gt;addFieldMapping('is_new')
      -&gt;defaultValue(TRUE);

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

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

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

    $this-&gt;addFieldMapping('field_image', 'uri')
      -&gt;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()
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.