Hi there --
I'm using migrate to move a bunch of data from a homegrown JSP/Postgres cms to D7, and all is going fairly well--I'm connecting to the Postgres database fine, and am able to import items without trouble. However, for some reason my migrate_map_* tables aren't getting populated. When I start the migration with
drush mi MigrationName
every single item that comes in triggers the following error messages:
Undefined property: stdClass::$style [error]
File /var/www/html/d7/sites/all/modules/contrib/migrate/includes/source.inc, line 257(file: /var/www/html/d7/sites/all/modules/contrib/migrate/includes/source.inc, line 257)
Undefined property: stdClass::$style
File /var/www/html/d7/sites/all/modules/contrib/migrate/plugins/sources/sqlmap.inc, line 301(file: /var/www/html/d7/sites/all/modules/contrib/migrate/plugins/sources/sqlmap.inc, line 301)Could not save to map table due to NULL value for key field style
This has been true for both nodes and terms (the old system had a taxonomy system), so I'm pretty sure it's not something I've done wrong in a particular Migration class, since I've set up two. I'm thinking it has something to do with using Postgres as my source? Anyway, here's one of my Migration classes for reference:
class ClearinghouseMigration extends Migration {
public function __construct() {
parent::__construct(MigrateGroup::getInstance('clearinghouse'));
$this->description = t('Migrate records and documents');
// Make sure the 2 term migrations happen first.
$this->dependencies = array('ChCat', 'ChTag');
$this->map = new MigrateSQLMap($this->machineName,
array(
'style' => array('type' => 'int',
'length' => 10,
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Source record ID',
)
),
MigrateDestinationNode::getKeySchema()
);
$query = Database::getConnection('default', 'phi_migrate')
->select('article', 'a')
->fields('a', array('art_author_fname', 'art_pubmonth', 'art_pubyear', 'art_date', 'art_volume', 'art_publisher', 'art_pub', 'art_http', 'art_binary', 'art_fulltext', 'art_order_details', 'art_entrydate', 'art_hardcopy', 'art_softcopy'));
$query->join('resource', 'r', 'a.res_id=r.res_id');
$query->fields('r', array('res_name', 'res_abstract'));
// Source
$this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE));
// Destination
$this->destination = new MigrateDestinationNode('articles_commentaries');
// Mappings
$this->addFieldMapping('title', 'res_name');
$this->addFieldMapping('body', 'res_abstract');
$this->addFieldMapping('field_author', 'art_author_fname');
$this->addFieldMapping('field_volume', 'art_volume');
$this->addFieldMapping('field_publisher', 'art_publisher');
$this->addFieldMapping('field_pub', 'art_pub');
$this->addFieldMapping('field_url', 'art_http');
$this->addFieldMapping('field_full_text_of_article', 'art_fulltext');
$this->addFieldMapping('field_ordering_info', 'art_order_details');
}
}
Thanks for any light you can shed. And thanks for this awesome module!
Ben
Comments
Comment #1
mikeryanHere's your problem:
There's no 'style' in your query. The name of the source key in the MigrateSQLMap constructor must a unique field in your source query.
Comment #2
bdimaggioThat is very, very satisfying to finally get right. Thanks so much for your help, Mike--all works perfectly now!
Comment #4
clemens.tolboomSee another example #1772888: MigrateDestinationTable migration failing with "Could not save to map table due to NULL value for key field fid" error mixing source key(s) with destination key(s)