<DBMIGRATION type="mod/glossary" VERSION="2005120100">
  <TABLES>
    <TABLE name="glossary_entries_categories" />
    <TABLE name="glossary_ratings" />
    <TABLE name="glossary_entries">
      <FIELDS>
        <FIELD name="concept" method="PLAIN_SQL_UPDATE" type="varchar" length="255" dropindex="concept" addindex="concept (concept(255))">
          <SQL_DETECT_USER>
           SELECT ge.userid
           FROM {$CFG->prefix}glossary_entries ge
           WHERE ge.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT g.course
           FROM {$CFG->prefix}glossary g,
                {$CFG->prefix}glossary_entries ge
           WHERE g.id = ge.glossaryid
                 AND ge.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="definition" method="PLAIN_SQL_UPDATE" type="text" length="0">
          <SQL_DETECT_USER>
           SELECT ge.userid
           FROM {$CFG->prefix}glossary_entries ge
           WHERE ge.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT g.course
           FROM {$CFG->prefix}glossary g,
                {$CFG->prefix}glossary_entries ge
           WHERE g.id = ge.glossaryid
                 AND ge.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="attachment" method="NO_CONV" type="varchar" length="100" />
      </FIELDS>
    </TABLE>
    <TABLE name="glossary_categories">
      <FIELDS>
        <FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
          <PHP_FUNCTION>
            migrate2utf8_glossary_categories(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
      </FIELDS>
    </TABLE>
    <TABLE name="glossary_comments">
      <FIELDS>
        <FIELD name="comment" method="PLAIN_SQL_UPDATE" type="text" length="0">
          <SQL_DETECT_USER>
           SELECT gco.userid
           FROM {$CFG->prefix}glossary_comments gco
           WHERE gco.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT g.course
           FROM {$CFG->prefix}glossary g,
                {$CFG->prefix}glossary_entries ge,
                {$CFG->prefix}glossary_comments gco
           WHERE g.id = ge.glossaryid
                 AND ge.id = gco.entryid
                 AND gco.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
      </FIELDS>
    </TABLE>
    <TABLE name="glossary_alias">
      <FIELDS>
        <FIELD name="alias" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
          <SQL_DETECT_USER>
           SELECT ge.userid
           FROM {$CFG->prefix}glossary_entries ge,
                {$CFG->prefix}glossary_alias ga
           WHERE ga.entryid = ge.id
                 AND ga.id = RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT g.course
           FROM {$CFG->prefix}glossary g,
                {$CFG->prefix}glossary_entries ge,
                {$CFG->prefix}glossary_alias ga
           WHERE g.id = ge.glossaryid
                 AND ge.id = ga.entryid
                 AND ga.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
      </FIELDS>
    </TABLE>
    <TABLE name="glossary_formats">
      <FIELDS>
        <FIELD name="name" method="NO_CONV" type="varchar" length="50" />
        <FIELD name="popupformatname" method="NO_CONV" type="varchar" length="50" />
        <FIELD name="defaultmode" method="NO_CONV" type="varchar" length="50" />
        <FIELD name="defaulthook" method="NO_CONV" type="varchar" length="50" />
        <FIELD name="sortkey" method="NO_CONV" type="varchar" length="50" />
        <FIELD name="sortorder" method="NO_CONV" type="varchar" length="50" />
      </FIELDS>
    </TABLE>
    <TABLE name="glossary">
      <FIELDS>
        <FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
          <PHP_FUNCTION>
            migrate2utf8_glossary_name(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
        <FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
          <PHP_FUNCTION>
            migrate2utf8_glossary_intro(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
        <FIELD name="displayformat" method="NO_CONV" type="varchar" length="50" default="dictionary" />
      </FIELDS>
    </TABLE>
  </TABLES>
</DBMIGRATION>
