# Large Drupal forum migration, importer errors and limitations

**URL:** <https://meta.discourse.org/t/large-drupal-forum-migration-importer-errors-and-limitations/246939>\
**Category:** Migration\
**Tags:** drupal\
**Created:** [November 28, 2022, 2:26pm UTC](https://meta.discourse.org/t/large-drupal-forum-migration-importer-errors-and-limitations/246939 "2022-11-28T14:26:50Z")\
**Posts on this page:** 1\
**Showing post:** 28

<div class="post-metadata">

**Author:** ![rahim123](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@rahim123](https://meta.discourse.org/u/rahim123)\
**Post date:** [February 7, 2023, 10:06pm UTC](https://meta.discourse.org/t/large-drupal-forum-migration-importer-errors-and-limitations/246939/28 "2023-02-07T22:06:14Z")

</div>

> [@rahim123](#):
>
> From my testing in phpMyAdmin on the Drupal database it looks like it simply needs an ` ORDER BY c.cid ASC` to maintain the correct threading order via the original Drupal comment ID `cid` which is is sequential and never changes.

OK, it looks like this works, it fixes the two jumbled threads I found and doesn’t seem to hurt anything else.

```plaintext
  def import_replies

```

…

```plaintext
    batches(BATCH_SIZE) do |offset|
      results = mysql_query(<<-SQL
        SELECT c.cid, c.pid, c.nid, c.uid, c.created,
               f.comment_body_value body,
               f.comment_body_format format
          FROM comment c,
               field_data_comment_body f,
               node n
         WHERE c.cid = f.entity_id
           AND n.nid = c.nid
           AND c.status = 1
           AND n.type IN ('poll', 'forum')
           AND n.status = 1
           AND c.created > UNIX_TIMESTAMP(STR_TO_DATE('#{IMPORT_AFTER}', '%Y-%m-%d'))
         ORDER BY c.cid ASC #<--- Fixed
         LIMIT #{BATCH_SIZE}
        OFFSET #{offset}
      SQL
      ).to_a

```

---

_[View the full topic](https://meta.discourse.org/t/large-drupal-forum-migration-importer-errors-and-limitations/246939)._
