Basically we wanted to move a portion of our drupal 6 site to our drupal 7 build. Using the migrate module. While migrating 155 nodes with their comments and taxonomy(2 vocabs, one is fixed the other is comma seperated) the last 30 fail giving me this error:
291 Error PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'tid' at row 1: INSERT INTO {taxonomy_index} (nid, tid, sticky, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 3057 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 1282050381 ) in taxonomy_field_insert() (line 1675 of /u01/facebase/drupal-7.0/modules/taxonomy/taxonomy.module).
291 Error SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'tid' at row 1
I'm migrating my terms using this query:
$query = db_select("$this->_db.term_data", 'td')
->fields('td', array('tid', 'name', 'weight'))
->condition('v.vid', 7);
$query->innerJoin("$this->_db.vocabulary", 'v', 'td.vid=v.vid');
I do this for 2 vocabularies, and then I map just the name, format, and weight. Then i'm using this query while migrating the nodes:
$query = db_select("$this->_db.node", 'n')
->fields('n', array('nid', 'vid', 'type', 'title', 'uid', 'status', 'created', 'changed', 'comment'))
->fields('tn', array('tid'))
->fields('nr', array('title', 'body', 'teaser'))
->condition('n.type', 'dev_content');
$query->leftJoin("$this->_db.term_node", 'tn', 'tn.vid =n.vid');
$query->leftJoin("$this->_db.node_revisions", 'nr', 'nr.vid = n.vid');
$query->addExpression('GROUP_CONCAT(DISTINCT tn.tid)', 'term_list');
$query->groupBy('n.nid');
Then i'm mapping the term_list for each vocabulary like this:
$this->addFieldMapping('field_dev_tags', 'term_list')
->separator(',')
->sourceMigration('DevCenterTerm')
->arguments(array('source_type' => 'tid'));
$this->addFieldMapping('field_dev_category', 'term_list')
->separator(',')
->sourceMigration('DevCenterTermPrep')
->arguments(array('source_type' => 'tid'));
I know this is happening due to the terms, as when i don't map the term_list all the nodes get created, but thats about it. Any ideas?
Is this an issue with those nodes not having a taxonomy assigned to them? If this is the case, try adding a default value to the taxonomy field mapping.
$this->addFieldMapping('field_dev_category', 'term_list')
->separator(',')
->sourceMigration('DevCenterTermPrep')
->arguments(array('source_type' => 'tid'))->defaultValue(12);
In the beer.inc example, this is documented in the comments:
You can also use both together - if a default value is provided in addition to a source field, the default value will be applied to any rows where the source field is empty or NULL.