<DBMIGRATION type="mod/forum" VERSION="2005120100">
  <TABLES>
    <TABLE name="forum_queue" />
    <TABLE name="forum_ratings" />
    <TABLE name="forum_read" />
    <TABLE name="forum_subscriptions" />
    <TABLE name="forum_track_prefs" />
    <TABLE name="forum_discussions">
      <FIELDS>
        <FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
          <SQL_DETECT_USER>
           SELECT fd.userid
           FROM {$CFG->prefix}forum_discussions fd
           WHERE fd.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT fd.course
           FROM {$CFG->prefix}forum_discussions fd
           WHERE fd.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
      </FIELDS>
    </TABLE>
    <TABLE name="forum_posts">
      <FIELDS>
        <FIELD name="subject" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
          <SQL_DETECT_USER>
           SELECT fp.userid
           FROM {$CFG->prefix}forum_posts fp
           WHERE fp.id = RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT fd.course
           FROM {$CFG->prefix}forum_discussions fd,
                {$CFG->prefix}forum_posts fp
           WHERE fd.id = fp.discussion
                 AND fp.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="message" method="PLAIN_SQL_UPDATE" type="text" length="0">
          <SQL_DETECT_USER>
           SELECT fp.userid
           FROM {$CFG->prefix}forum_posts fp
           WHERE fp.id = RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT fd.course
           FROM {$CFG->prefix}forum_discussions fd,
                {$CFG->prefix}forum_posts fp
           WHERE fd.id = fp.discussion
                 AND fp.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="attachment" method="NO_CONV" type="varchar" length="100" />
      </FIELDS>
    </TABLE>
    <TABLE name="forum">
      <FIELDS>
        <FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
          <PHP_FUNCTION>
            migrate2utf8_forum_name(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
        <FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
          <PHP_FUNCTION>
            migrate2utf8_forum_intro(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
        <FIELD name="type" method="NO_CONV" type="enum('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda')" length="0" default="general"/>
      </FIELDS>
    </TABLE>
  </TABLES>
</DBMIGRATION>
