将 drupal 6 迁移到 drupal 7

发布于 2024-11-19 05:51:57 字数 2107 浏览 4 评论 0原文

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

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 不正确的整数值:列的“” 'tid' 在第 1 行

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

$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 个词汇表执行此操作,然后仅映射名称、格式和重量。然后我在迁移节点时使用此查询:

$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,如下所示:

$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 时,所有节点都会被创建,但仅此而已。有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风追烟花雨 2024-11-26 05:51:57

这是那些没有分配分类法的节点的问题吗?如果是这种情况,请尝试向分类字段映射添加默认值。

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

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

您也可以一起使用两者 - 如果在中提供了默认值
除了源字段之外,默认值将应用于任何
源字段为空或 NULL 的行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文