Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'destid1' in 'field list': INSERT INTO {migrate_map_anbientbanner} (sourceid1, needs_update, destid1) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 6351 [:db_insert_placeholder_1] => 0 [:db_insert_placeholder_2] => 16 ) (/mysite/sites/all/modules/contrib/migrate/plugins/sources/sqlmap.inc:319)
Processed 1 (1 created, 0 updated, 1 failed, 0 ignored) in 4.2 sec (14/min) - done with 'AnbientBanner'
class AnbientBannerMigration extends AnbientV3Migration {
public function __construct() {
parent::__construct();
$this->description = 'Migra os Banners da V3';
$this->map = new MigrateSQLMap($this->machineName,
array(
'fid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'BANNER',
'alias' => 'f'
)
),
MigrateDestinationEntityAPI::getKeySchema()
);
$query = db_select('node', 'n', array('target' => 'V3_DB'));
$query->condition('n.type', 'banner_rotativo');
$query->fields('n', array('nid', 'uid', 'changed', 'created'));
$query->leftJoin('content_type_banner_rotativo', 'ctbr', 'n.vid = ctbr.vid');
$query->addField('ctbr', 'field_bnner_an_relacionado_nid', 'anime_relacionado');
$query->leftJoin('content_field_imagem_banner', 'cfib', 'n.vid = cfib.vid');
$query->leftJoin('files', 'f', 'cfib.field_imagem_banner_fid = f.fid');
$query->fields('f', array('fid', 'filepath'));
$query->orderBy('changed');
$this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE));
$this->destination = new MigrateDestinationEntityAPI('destaque', 'banner');
$this->highwaterField = array(
'name' => 'changed',
'alias' => 'n',
'type' => 'int',
);
$this->addSimpleMappings(array('uid', 'changed', 'created'));
$this->addFieldMapping('type')->defaultValue('banner');
$this->addFieldMapping('field_imagem', 'filepath');
$this->addFieldMapping('field_imagem:preserve_files')->defaultValue(TRUE);
$this->addFieldMapping('field_imagem:file_replace')->defaultValue(MigrateFile::FILE_EXISTS_REUSE);
$this->addFieldMapping('field_imagem:source_dir')->defaultValue('http://anbient.net/');
$this->addFieldMapping('field_relac_anime', 'anime_relacionado');
$this->addUnmigratedDestinations(array('path'));
}
public function prepareRow($row) {
dpm($row);
return FALSE;
}
}
Preview of the query:
http://i49.tinypic.com/346u9p3.png
Comments
Comment #1
mikeryanThe fact the destid1 was not created in your map table means that the destination key argument to the map constructor isn't working properly - specifically, you did not pass the entity type to MigrateDestinationEntityAPI::getKeySchema(). It should be MigrateDestinationEntityAPI::getKeySchema('destaque').
You'll have to drop the migrate_map_anbientbanner table, so it will get recreated correctly.
Comment #2
Fidelix CreditAttribution: Fidelix commentedNow I suddenly understand how MigrateDestinationSTUFFHERE::getKeySchema() works, and a lot other things also were cleared up on my mind.
Thank you so much, Mike.
Comment #4
jessehsI ran into this problem when dealing with the commerce_migrate module, whose MigrateDestinationCommerceProduct class extends the MigrateDestinationEntityAPI class.
For others that run into this issue, "commerce_product" is the entity_type to pass to getKeySchema.
In a slightly-related note, the entity bundle is the product type. So do something like this when creating the destination:
Comment #5
estoyausenteI had the same problem and the #1 solution works for me. I only had to add the entity_type in the getKeySchema params function. Remove migration and register again. Thanks