<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="local/kopere_dashboard/plugins/attest/db" VERSION="2026030500" COMMENT="Attest tables"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="../../../../../lib/xmldb/xmldb.xsd">
    <TABLES>

        <TABLE NAME="koperedashboard_attest_tpl" COMMENT="Attestation templates (HTML).">
            <FIELDS>
                <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
                <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="html" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="validmonths" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="12" SEQUENCE="false"/>
                <FIELD NAME="allcourses" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
                <FIELD NAME="active" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
                <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="createdby" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
            </FIELDS>
            <KEYS>
                <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
            </KEYS>
            <INDEXES>
                <INDEX NAME="idx_active" UNIQUE="false" FIELDS="active"/>
                <INDEX NAME="idx_allcourses" UNIQUE="false" FIELDS="allcourses"/>
            </INDEXES>
        </TABLE>

        <TABLE NAME="koperedashboard_attest_tpl_course" COMMENT="Template courses mapping when not allcourses.">
            <FIELDS>
                <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
                <FIELD NAME="tplid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
            </FIELDS>
            <KEYS>
                <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
            </KEYS>
            <INDEXES>
                <INDEX NAME="idx_tpl_course" UNIQUE="true" FIELDS="tplid,courseid"/>
            </INDEXES>
        </TABLE>

        <TABLE NAME="koperedashboard_attest_issue" COMMENT="Generated attestations (token + dates).">
            <FIELDS>
                <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
                <FIELD NAME="tplid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="token" TYPE="char" LENGTH="12" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="validuntil" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="html" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="htmlsha1" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false"/>
                <FIELD NAME="ip" TYPE="char" LENGTH="45" NOTNULL="false" SEQUENCE="false"/>
                <FIELD NAME="useragent" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
            </FIELDS>
            <KEYS>
                <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
            </KEYS>
            <INDEXES>
                <INDEX NAME="idx_token" UNIQUE="true" FIELDS="token"/>
                <INDEX NAME="idx_user_course" UNIQUE="false" FIELDS="userid,courseid"/>
            </INDEXES>
        </TABLE>

    </TABLES>
</XMLDB>
