将 drupal 6 迁移到 drupal 7

Migrating drupal 6 to drupal 7

基本上,我们希望将我们的 drupal 6 网站的一部分移至我们的 drupal 7 版本。使用迁移模块。在迁移 155 个节点及其注释和分类时(2 个词汇,一个是固定的,另一个是逗号分隔的)最后 30 个失败给我这个错误:

1
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 错误 SQLSTATE[HY000]:一般错误:1366 不正确的整数值:第 1 行的列 \\'tid\\' 的 \\'\\'

我正在使用此查询迁移我的术语:

1
2
3
4
$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');

我对 2 个词汇表执行此操作,然后仅映射名称、格式和权重。然后我在迁移节点时使用此查询:

1
2
3
4
5
6
7
8
9
10
$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');

然后我将像这样为每个词汇表映射 term_list:

1
2
3
4
5
6
7
8
9
$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'));

我知道这是由于条款而发生的,因为当我不映射 term_list 时,所有节点都会被创建,但仅此而已。有什么想法吗?


这些节点没有分配给它们的分类是否存在问题?如果是这种情况,请尝试向分类字段映射添加默认值。

1
2
3
4
    $this->addFieldMapping('field_dev_category', 'term_list')
 ->separator(',')
 ->sourceMigration('DevCenterTermPrep')
 ->arguments(array('source_type' => 'tid'))->defaultValue(12);

在 beer.inc 示例中,注释中记录了这一点:

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.