<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/motrain/db" VERSION="20230923" COMMENT="XMLDB file for Moodle blocks/motrain"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
  <TABLES>
    <TABLE NAME="block_motrain_comprules" COMMENT="The completion rules.">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The course ID, of 0."/>
        <FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The course module ID, or 0."/>
        <FIELD NAME="modname" TYPE="char" LENGTH="64" NOTNULL="false" SEQUENCE="false" COMMENT="The module name, or null."/>
        <FIELD NAME="coins" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The number of coins."/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="coursecmmod" UNIQUE="true" FIELDS="courseid, cmid, modname"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_motrain_msgtpl" COMMENT="Message templates">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
        <FIELD NAME="code" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="lang" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
        <FIELD NAME="subject" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="content" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="contentformat" TYPE="int" LENGTH="1" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="codelang" UNIQUE="true" FIELDS="code, lang"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_motrain_log" COMMENT="The log of collections.">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="coins" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="actionname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="actionhash" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="timebroadcasted" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
        <FIELD NAME="broadcasterror" TYPE="char" LENGTH="512" NOTNULL="false" SEQUENCE="false" COMMENT="The last error encountered when the broadcast failed."/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="actionnamehash" UNIQUE="false" FIELDS="actionname, actionhash"/>
        <INDEX NAME="userctxactiontime" UNIQUE="false" FIELDS="userid, contextid, actionname, actionhash, timecreated"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_motrain_playermap" COMMENT="The user-player mappings">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="accountid" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="playerid" TYPE="char" LENGTH="128" NOTNULL="false" SEQUENCE="false"/>
        <FIELD NAME="teamid" TYPE="char" LENGTH="128" NOTNULL="false" SEQUENCE="false" COMMENT="The team ID when the mapping was created. Null for previous records."/>
        <FIELD NAME="metadatahash" TYPE="char" LENGTH="40" NOTNULL="false" SEQUENCE="false"/>
        <FIELD NAME="metadatastale" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
        <FIELD NAME="blocked" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
        <FIELD NAME="blockedreason" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="useraccount" UNIQUE="true" FIELDS="userid, accountid"/>
        <INDEX NAME="useraccountmetadata" UNIQUE="false" FIELDS="userid, accountid, metadatahash"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_motrain_programrules" COMMENT="Default comment for the table, please edit me">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
        <FIELD NAME="programid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
        <FIELD NAME="coins" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="programid" UNIQUE="true" FIELDS="programid"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_motrain_teammap" COMMENT="The cohort-team mappings.">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
        <FIELD NAME="cohortid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="accountid" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="teamid" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="cohortaccount" UNIQUE="true" FIELDS="cohortid, accountid"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_motrain_userspush" COMMENT="List of users to push to Motrain.">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid" COMMENT="An index on user ID. It's not unique because we don't care if there are duplicates."/>
      </INDEXES>
    </TABLE>
  </TABLES>
</XMLDB>
