<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="local/ascend_rewards/db" VERSION="20251201" COMMENT="XMLDB file for badge activity cache"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
  <TABLES>
    <TABLE NAME="local_ascend_badge_cache" COMMENT="Caches badge qualifying activities for fast retrieval">
      <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="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="badgeid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="activities" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="JSON array of activity names"/>
        <FIELD NAME="metadata" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="JSON array of metadata (award numbers, grouping, etc)"/>
        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="userid_courseid_badgeid" UNIQUE="true" FIELDS="userid, courseid, badgeid"/>
        <INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid"/>
        <INDEX NAME="badgeid" UNIQUE="false" FIELDS="badgeid"/>
      </INDEXES>
    </TABLE>
  </TABLES>
</XMLDB>
