<DBMIGRATION type="mod/wiki" VERSION="2005120100">
  <TABLES>
    <TABLE name="wiki_entries">
      <FIELDS>
        <FIELD name="pagename" method="PLAIN_SQL_UPDATE" type="varchar" length="255" dropindex="pagename" addindex="pagename(pagename(255))">
          <SQL_DETECT_USER>
           SELECT we.userid
           FROM {$CFG->prefix}wiki_entries we
           WHERE we.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT w.course
           FROM {$CFG->prefix}wiki w,
                {$CFG->prefix}wiki_entries we
           WHERE w.id = we.wikiid
                 AND we.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
      </FIELDS>
    </TABLE>
    <TABLE name="wiki_pages">
      <FIELDS>
        <FIELD name="pagename" method="PLAIN_SQL_UPDATE" type="varchar" length="160" dropindex="wiki_pages_uk" addindex="wiki_pages_uk(pagename(160), version, wiki)">
          <SQL_DETECT_USER>
           SELECT wp.userid
           FROM {$CFG->prefix}wiki_pages wp
           WHERE wp.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT w.course
           FROM {$CFG->prefix}wiki w,
                {$CFG->prefix}wiki_pages wp
           WHERE w.id = wp.wiki
                 AND wp.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="content" method="PLAIN_SQL_UPDATE" type="mediumtext" length="0">
          <SQL_DETECT_USER>
           SELECT wp.userid
           FROM {$CFG->prefix}wiki_pages wp
           WHERE wp.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT w.course
           FROM {$CFG->prefix}wiki w,
                {$CFG->prefix}wiki_pages wp
           WHERE w.id = wp.wiki
                 AND wp.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="author" method="PLAIN_SQL_UPDATE" type="varchar" length="100" default="ewiki">
          <SQL_DETECT_USER>
           SELECT wp.userid
           FROM {$CFG->prefix}wiki_pages wp
           WHERE wp.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT w.course
           FROM {$CFG->prefix}wiki w,
                {$CFG->prefix}wiki_pages wp
           WHERE w.id = wp.wiki
                 AND wp.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="refs" method="PLAIN_SQL_UPDATE" type="mediumtext" length="0">
          <SQL_DETECT_USER>
           SELECT wp.userid
           FROM {$CFG->prefix}wiki_pages wp
           WHERE wp.id=RECORDID
          </SQL_DETECT_USER>
          <SQL_DETECT_COURSE>
           SELECT w.course
           FROM {$CFG->prefix}wiki w,
                {$CFG->prefix}wiki_pages wp
           WHERE w.id = wp.wiki
                 AND wp.id = RECORDID
          </SQL_DETECT_COURSE>
        </FIELD>
        <FIELD name="meta" method="NO_CONV" type="mediumtext" length="0" />
      </FIELDS>
    </TABLE>
    <TABLE name="wiki">
      <FIELDS>
        <FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
          <PHP_FUNCTION>
            migrate2utf8_wiki_name(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
        <FIELD name="summary" method="PHP_FUNCTION" type="text" length="0">
          <PHP_FUNCTION>
            migrate2utf8_wiki_summary(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
        <FIELD name="pagename" method="PHP_FUNCTION" type="varchar" length="255">
          <PHP_FUNCTION>
            migrate2utf8_wiki_pagename(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
        <FIELD name="wtype" method="NO_CONV" type="enum('teacher', 'group', 'student')" length="0" default="group" />
        <FIELD name="initialcontent" method="PHP_FUNCTION" type="varchar" length="255">
          <PHP_FUNCTION>
            migrate2utf8_wiki_initialcontent(RECORDID)
          </PHP_FUNCTION>
        </FIELD>
      </FIELDS>
    </TABLE>
  </TABLES>
</DBMIGRATION>
