Warning, /pim/akonadi/autotests/server/dbtest_data/unittest_schema.xml is written in an unsupported language. File is not indexed.

0001 <?xml version="1.0" encoding="UTF-8"?>
0002 <!--
0003 
0004     SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org>
0005     SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 
0009 -->
0010 
0011 
0012 <!--
0013   Akonadi Database Schema Definition
0014 
0015   This file is used to generate database access code as well as the tables itself.
0016 
0017   Database element (root node, can contain table and relation elements)
0018 
0019   Table attributes (can contain column, reference and data elements)
0020   - name: The entity class name, the table will be named FooTable.
0021 
0022   Column attributes:
0023   - name: The column name, will be also used as accessor name in the entity class.
0024   - type: The C++ type of this column, the SQL type will be derived from that.
0025   - size: The size of the SQL column (optional, semantic depends on "type")
0026   - default: Default value for entity class constructor.
0027   - refTable, refColumn: foreign key, also used to generate accessor methods for 1:n relations
0028   - methodName: method name to access referred records, the table name is used if not given
0029   - onUpdate, onDelete: referential actions for foreign keys
0030 
0031   Indices:
0032   - name: The name of the index
0033   - columns: The columns covered by this index
0034   - unique: bool, indicates if this index must contain unique data
0035 
0036   Reference attributes (indication n:1 relations)
0037   - name: Used for naming the method during code generation
0038   - table: name of the table a n:1 relation exist
0039   - key: column name of the referenced table containing the foreign key
0040 
0041   Initial data:
0042   - columns: A comma separated list of column names
0043   - values: A comma separated and SQL-quoted list of values
0044 
0045   Relation elements define a n:m relation between two tables.
0046   Attributes:
0047   - table[12]: Table names
0048   - column[12]: Column names
0049 
0050 -->
0051 <database>
0052 
0053   <table name="SchemaVersion">
0054     <comment>Contains the schema version of the database.</comment>
0055     <column name="version" type="int" default="0" allowNull="false"/>
0056     <column name="generation" type="int" default="0" allowNull="false" />
0057     <data columns="version" values="36"/>
0058   </table>
0059 
0060   <table name="Resource">
0061     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0062     <column name="name" type="QString" allowNull="false" isUnique="true"/>
0063     <column name="isVirtual" type="bool" default="false"/>
0064     <reference name="collections" table="Collection" key="resourceId"/>
0065     <data columns="name,isVirtual" values="'akonadi_search_resource',true"/>
0066   </table>
0067 
0068   <table name="Collection">
0069     <enum name="Tristate">
0070       <value name="False"/>
0071       <value name="True"/>
0072       <value name="Undefined"/>
0073     </enum>
0074 
0075     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0076     <column name="remoteId" type="QString"/>
0077     <column name="remoteRevision" type="QString"/>
0078     <column name="name" type="QString" allowNull="false"/>
0079     <column name="parentId" type="qint64" refTable="Collection" refColumn="id" methodName="parent"/>
0080     <column name="resourceId" type="qint64" refTable="Resource" refColumn="id" allowNull="false"/>
0081     <column name="enabled" type="bool" default="true" allowNull="false"/>
0082     <column name="syncPref" type="enum" enumType="Tristate" default="Tristate::Undefined"/>
0083     <column name="displayPref" type="enum" enumType="Tristate" default="Tristate::Undefined"/>
0084     <column name="indexPref" type="enum" enumType="Tristate" default="Tristate::Undefined"/>
0085     <column name="referenced" type="bool" default="false" allowNull="false"/>
0086     <column name="cachePolicyInherit" type="bool" default="true" allowNull="false"/>
0087     <column name="cachePolicyCheckInterval" type="int" default="-1" allowNull="false"/>
0088     <column name="cachePolicyCacheTimeout" type="int" default="-1" allowNull="false"/>
0089     <column name="cachePolicySyncOnDemand" type="bool" default="false" allowNull="false"/>
0090     <column name="cachePolicyLocalParts" type="QString"/>
0091     <column name="queryString" type="QString" size="32768"/>
0092     <column name="queryAttributes" type="QString"/>
0093     <column name="queryCollections" type="QString"/>
0094     <column name="isVirtual" type="bool" default="false"/>
0095     <index name="parentAndNameIndex" columns="parentId,name" unique="true"/>
0096     <index name="parentIndex" columns="parentId" unique="false"/>
0097     <index name="resourceIndex" columns="resourceId" unique="false"/>
0098     <index name="enabledIndex" columns="enabled" unique="false"/>
0099     <index name="syncPrefIndex" columns="syncPref" unique="false"/>
0100     <index name="displayPrefIndex" columns="displayPref" unique="false"/>
0101     <index name="indexPrefIndex" columns="indexPref" unique="false"/>
0102     <reference name="children" table="Collection" key="parentId"/>
0103     <reference name="items" table="PimItem" key="collectionId"/>
0104     <reference name="attributes" table="CollectionAttribute" key="collectionId"/>
0105     <data columns="parentId,name,resourceId,isVirtual" values="NULL,'Search',1,true"/>
0106   </table>
0107 
0108   <table name="MimeType">
0109     <comment>This meta data is stored inside akonadi to provide fast access.</comment>
0110     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0111     <column name="name" type="QString" allowNull="false" isUnique="true"/>
0112   </table>
0113 
0114   <table name="PimItem">
0115     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0116     <column name="rev" type="int" default="0" allowNull="false"/>
0117     <column name="remoteId" type="QString"/>
0118     <column name="remoteRevision" type="QString"/>
0119     <column name="gid" type="QString"/>
0120     <column name="collectionId" type="qint64" refTable="Collection" refColumn="id"/>
0121     <column name="mimeTypeId" type="qint64" refTable="MimeType" refColumn="id" onDelete="Restrict"/>
0122     <column name="datetime" type="QDateTime" default="QDateTime::currentDateTimeUtc()">
0123       <comment>create/modified time</comment>
0124     </column>
0125     <column name="atime" type="QDateTime" default="QDateTime::currentDateTimeUtc()">
0126       <comment>read access time</comment>
0127     </column>
0128     <column name="dirty" type="bool">
0129       <comment>Indicates that this item has unsaved changes.</comment>
0130     </column>
0131     <column name="size" type="qint64" default="0" allowNull="false"/>
0132     <index name="collectionIndex" columns="collectionId" unique="false"/>
0133     <index name="mimeTypeIndex" columns="mimeTypeId" unique="false"/>
0134     <index name="gidIndex" columns="gid" unique="false"/>
0135     <index name="ridIndex" columns="remoteId" unique="false"/>
0136     <index name="idSortIndex" columns="id" unique="false" sort="DESC"/>
0137     <reference name="parts" table="Part" key="pimItemId"/>
0138   </table>
0139 
0140   <table name="Flag">
0141     <comment>This meta data is stored inside akonadi to provide fast access.</comment>
0142     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0143     <column name="name" type="QString" allowNull="false" isUnique="true"/>
0144   </table>
0145 
0146  <table name="PartType">
0147    <comment>Table containing item part types.</comment>
0148    <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0149    <column name="name" type="QString" allowNull="false">
0150      <comment>Part name, without namespace.</comment>
0151    </column>
0152    <column name="ns" type="QString" allowNull="false">
0153      <comment>Part namespace.</comment>
0154    </column>
0155    <index name="partTypeNameIndex" columns="ns,name" unique="true"/>
0156  </table>
0157 
0158   <table name="Part">
0159     <enum name="Storage">
0160       <value name="Internal"/>
0161       <value name="External"/>
0162       <value name="Foreign"/>
0163     </enum>
0164     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0165     <column name="pimItemId" type="qint64" refTable="PimItem" refColumn="id" allowNull="false"/>
0166     <column name="partTypeId" type="qint64" refTable="PartType" refColumn="id" allowNull="false" noUpdate="true" />
0167     <column name="data" type="QByteArray"/>
0168     <column name="datasize" type="qint64" allowNull="false"/>
0169     <column name="version" type="int" default="0"/>
0170     <column name="storage" type="enum" enumType="Storage" default="Internal"/>
0171     <index name="pimItemIdTypeIndex" columns="pimItemId,partTypeId" unique="true"/>
0172     <index name="pimItemIdSortIndex" columns="pimItemId" unique="false" sort="DESC"/>
0173     <index name="partTypeIndex" columns="partTypeId" unique="false"/>
0174   </table>
0175 
0176   <table name="CollectionAttribute">
0177     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0178     <column name="collectionId" type="qint64" refTable="Collection" refColumn="id" allowNull="false"/>
0179     <column name="type" type="QByteArray" allowNull="false"/>
0180     <column name="value" type="QByteArray"/>
0181     <index name="collectionIndex" columns="collectionId" unique="false"/>
0182   </table>
0183 
0184   <table name="TagType">
0185     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0186     <column name="name" type="QString" allowNull="false" isUnique="true"/>
0187     <data columns="name" values="'PLAIN'"/>
0188   </table>
0189 
0190   <table name="Tag">
0191     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0192     <column name="gid" type="QString" allowNull="false"/>
0193     <column name="parentId" type="qint64" refTable="Tag" refColumn="id" allowNull="true" methodName="parent"/>
0194     <column name="typeId" type="qint64" refTable="TagType" refColumn="id" onDelete="Restrict" default="1"/>
0195     <index name="parentIndex" columns="parentId" unique="false"/>
0196     <index name="typeIndex" columns="typeId" unique="false"/>
0197   </table>
0198 
0199   <table name="TagAttribute">
0200     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0201     <column name="tagId" type="qint64" allowNull="false" refTable="Tag" refColumn="id"/>
0202     <column name="type" type="QByteArray" allowNull="false"/>
0203     <column name="value" type="QByteArray"/>
0204     <index name="tagIndex" columns="tagId" unique="false"/>
0205   </table>
0206 
0207   <table name="TagRemoteIdResourceRelation" identificationColumn="">
0208     <column name="tagId" type="qint64" allowNull="false" refTable="Tag" refColumn="id" onDelete="Cascade" />
0209     <column name="resourceId"  type="qint64" allowNull="false" refTable="Resource" refColumn="id" onDelete="Cascade" />
0210     <column name="remoteId" type="QString" allowNull="false" />
0211     <index name="TagAndResourceIndex" columns="tagId,resourceId" unique="true"/>
0212     <index name="tagIndex" columns="tagId"/>
0213     <index name="resourceIndex" columns="resourceId"/>
0214   </table>
0215 
0216   <table name="RelationType">
0217     <column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
0218     <column name="name" type="QString" allowNull="false" isUnique="true"/>
0219     <data columns="name" values="'GENERIC'"/>
0220   </table>
0221 
0222   <table name="Relation" identificationColumn="">
0223     <column name="leftId" type="qint64" allowNull="false" refTable="PimItem" refColumn="id" onDelete="Cascade" methodName="left" />
0224     <column name="rightId"  type="qint64" allowNull="false" refTable="PimItem" refColumn="id" onDelete="Cascade" methodName="right" />
0225     <column name="typeId" type="qint64" refTable="RelationType" refColumn="id" onDelete="Restrict" default="1"/>
0226     <column name="remoteId" type="QString" />
0227     <index name="RelationIndex" columns="leftId,rightId,typeId" unique="true"/>
0228     <index name="leftIndex" columns="leftId" unique="false"/>
0229     <index name="rightIndex" columns="rightId" unique="false"/>
0230     <index name="typeIndex" columns="typeId" unique="false"/>
0231   </table>
0232 
0233   <relation table1="PimItem" column1="id" table2="Flag" column2="id">
0234     <index name="pimItemIdSortIndex" columns="pimitem_id" unique="false" sort="DESC"/>
0235   </relation>
0236 
0237   <relation table1="PimItem" column1="id" table2="Tag" column2="id"/>
0238 
0239   <relation table1="Collection" column1="id" table2="MimeType" column2="id">
0240     <comment>Specifies allowed MimeType for a Collection</comment>
0241   </relation>
0242 
0243   <relation table1="Collection" column1="id" table2="PimItem" column2="id">
0244     <comment>Used to associate items with search folders.</comment>
0245   </relation>
0246 </database>