<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
	<name>*dbname*</name>
	<create>true</create>
	<overwrite>false</overwrite>
	<charset>utf8</charset>
	<table>
		<name>*dbprefix*richdocuments_session</name>
		<declaration>
			
			<field>
				<name>es_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Editing session id</comments>
			</field>
			<field>
				<name>genesis_url</name>
				<type>text</type>
				<length>512</length>
				<comments>Relative to owner documents storage /welcome.odt</comments>
			</field>
			<field>
				<name>genesis_hash</name>
				<type>text</type>
				<length>128</length>
				<notnull>true</notnull>
				<comments>To be sure the genesis did not change</comments>
			</field>
			<field>
				<name>file_id</name>
				<type>text</type>
				<length>512</length>
				<comments>Relative to storage e.g. /welcome.odt</comments>
			</field>
			<field>
				<name>owner</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>oC user who created the session</comments>
			</field>
			
			<index>
				<name>richdocuments_session_ei_idx</name>
				<primary>true</primary>
				<unique>true</unique>
				<field>
					<name>es_id</name>
					<sorting>ascending</sorting>
				</field>
			</index>
			
		</declaration>
	</table>
	
	<table>
		<name>*dbprefix*richdocuments_member</name>
		<declaration>
			
			<field>
				<name>member_id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>1</autoincrement>
				<unsigned>true</unsigned>
				<length>4</length>
				<comments>Unique per user and session</comments>
			</field>
			<field>
				<name>es_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Related editing session id</comments>
			</field>
			<field>
				<name>uid</name>
				<type>text</type>
				<length>64</length>
			</field>
			<field>
				<name>color</name>
				<type>text</type>
				<length>32</length>
			</field>
			<field>
				<name>last_activity</name>
				<type>integer</type>
				<unsigned>true</unsigned>
				<length>4</length>
			</field>
			<field>
				<name>is_guest</name>
				<type>integer</type>
				<default>0</default>
				<notnull>true</notnull>
				<unsigned>true</unsigned>
				<length>1</length>
			</field>
			<field>
				<name>token</name>
				<type>text</type>
				<default></default>
				<notnull>false</notnull>
				<length>32</length>
			</field>
			<field>
				<name>status</name>
				<type>integer</type>
				<default>1</default>
				<notnull>true</notnull>
				<unsigned>true</unsigned>
				<length>1</length>
			</field>
			
		</declaration>
	</table>
		
	<table>
		<name>*dbprefix*richdocuments_op</name>
		<declaration>
			
			<field>
				<name>seq</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>1</autoincrement>
				<unsigned>true</unsigned>
				<length>4</length>
				<comments>Sequence number</comments>
			</field>
			<field>
				<name>es_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Editing session id</comments>
			</field>
			<field>
				<name>member</name>
				<type>integer</type>
				<default>1</default>
				<notnull>true</notnull>
				<unsigned>true</unsigned>
				<length>4</length>
				<comments>User and time specific</comments>
			</field>
			<field>
				<name>optype</name>
				<type>text</type>
				<notnull>false</notnull>
				<length>64</length>
				<comments>Operation type</comments>
			</field>
			<field>
				<name>opspec</name>
				<type>clob</type>
				<notnull>false</notnull>
				<comments>json-string</comments>
			</field>
			
			<index>
				<name>richdocs_seq_pKey</name>
				<primary>true</primary>
				<field>
					<name>seq</name>
					<sorting>ascending</sorting>
				</field>
			</index>
			<index>
				<name>richdocuments_op_eis_idx</name>
				<unique>true</unique>
				<field>
					<name>es_id</name>
					<sorting>ascending</sorting>
				</field>
				<field>
					<name>seq</name>
					<sorting>ascending</sorting>
				</field>
			</index>
			
		</declaration>
	</table>
	<table>
		<name>*dbprefix*richdocuments_invite</name>
		<declaration>
			
			<field>
				<name>es_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Related editing session id</comments>
			</field>
			<field>
				<name>uid</name>
				<type>text</type>
				<length>64</length>
			</field>
			<field>
				<name>status</name>
				<type>integer</type>
				<default>0</default>
				<length>2</length>
			</field>
			<field>
				<name>sent_on</name>
				<type>integer</type>
				<default></default>
				<notnull>false</notnull>
				<unsigned>true</unsigned>
				<length>4</length>
			</field>
			
		</declaration>
	</table>
	<table>
		<name>*dbprefix*richdocuments_revisions</name>
		<declaration>
			
			<field>
				<name>es_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Related editing session id</comments>
			</field>
			<field>
				<name>seq_head</name>
				<type>integer</type>
				<notnull>true</notnull>
				<unsigned>true</unsigned>
				<length>4</length>
				<comments>Sequence head number</comments>
			</field>
			<field>
				<name>member_id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<unsigned>true</unsigned>
				<length>4</length>
				<comments>the member that saved the revision</comments>
			</field>
			<field>
				<name>file_id</name>
				<type>text</type>
				<length>512</length>
				<comments>Relative to storage e.g. /welcome.odt</comments>
			</field>
			<field>
				<name>save_hash</name>
				<type>text</type>
				<length>128</length>
				<notnull>true</notnull>
				<comments>used to lookup revision in documents folder of member, eg hash.odt</comments>
			</field>
			
			<index>
				<name>richdocuments_rev_eis_idx</name>
				<unique>true</unique>
				<field>
					<name>es_id</name>
					<sorting>ascending</sorting>
				</field>
				<field>
					<name>seq_head</name>
					<sorting>ascending</sorting>
				</field>
			</index>
			
		</declaration>
	</table>
	
	<table>
		<name>*dbprefix*richdocuments_wopi</name>
		<declaration>
			<field>
				<name>id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>1</autoincrement>
				<unsigned>true</unsigned>
				<length>4</length>
				<comments>Unique per token</comments>
			</field>
			<field>
				<name>uid</name>
				<type>text</type>
				<length>64</length>
				<comments>UserId - a textual user identifier (unique?)</comments>
			</field>
			<field>
				<name>fileid</name>
				<type>integer</type>
				<notnull>true</notnull>
				<length>4</length>
				<comments>The unique ID of the file authorized</comments>
			</field>
			<field>
				<name>path</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>512</length>
				<comments>Relative to storage e.g. /welcome.odt</comments>
			</field>
			<field>
				<name>token</name>
				<type>text</type>
				<default></default>
				<notnull>true</notnull>
				<length>32</length>
				<comments>File access token</comments>
			</field>
			<field>
				<name>expiry</name>
				<type>integer</type>
				<unsigned>true</unsigned>
				<length>4</length>
				<comments>Expiration time of the token</comments>
			</field>
		</declaration>
	</table>
</database>
