<DBMIGRATION type="mod/chat" VERSION="2005120100">
  <TABLES>
    <TABLE name="chat_users">
      <FIELDS>
        <FIELD name="version" method="NO_CONV" type="varchar" length="16" />
        <FIELD name="ip" method="NO_CONV" type="varchar" length="15" />
        <FIELD name="sid" method="NO_CONV" type="varchar" length="32" />
        <FIELD name="lang" method="NO_CONV" type="varchar" length="10" />
      </FIELDS>
    </TABLE>
    <TABLE name="chat_messages">
      <FIELDS>
        <FIELD name="message" method="PLAIN_SQL_UPDATE" type="text" length="0">
          <SQL_DETECT_USER>
           SELECT chm.userid
           FROM {$CFG->prefix}chat_messages chm
           WHERE chm.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT ch.course
           FROM {$CFG->prefix}chat ch,
                {$CFG->prefix}chat_messages chm
           WHERE ch.id = chm.chatid
                 AND chm.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
      </FIELDS>
    </TABLE>
    <TABLE name="chat">
      <FIELDS>
        <FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
          <SQL_DETECT_COURSE>
            migrate2utf8_chat_name(RECORDID)
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
          <SQL_DETECT_COURSE>
            migrate2utf8_chat_intro(RECORDID)
          </SQL_DETECT_COURSE>
        </FIELD>
      </FIELDS>
    </TABLE>
  </TABLES>
</DBMIGRATION>
