<?xml version="1.0"?>
<schema version="0.2">

	<!-- phpGACL Table -->
	<table name="phpgacl">
		<field name="name" type="C" size="230">
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
		</field>
	</table>
	<sql>
		<descr>SQL to be executed only to insert default rows</descr>
		<query>
			DELETE FROM phpgacl WHERE name='version'
		</query>
		<query>
			INSERT INTO phpgacl (name,value) VALUES ('version','3.3.7')
		</query>
		<query>
			DELETE FROM phpgacl WHERE name='schema_version'
		</query>
		<query>
			INSERT INTO phpgacl (name,value) VALUES ('schema_version','2.1')
		</query>
	</sql>

	<!-- ACL Table -->
	<table name="acl">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="section_value" type="C" size="230">
			<DEFAULT value="system"/>
			<NOTNULL/>
		</field>
		<field name="allow" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="enabled" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="return_value" type="X">
		</field>
		<field name="note" type="X">
		</field>
		<field name="updated_date" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="enabled_acl">
			<col>enabled</col>
		</index>
		<index name="section_value_acl">
			<col>section_value</col>
		</index>
		<index name="updated_date_acl">
			<col>updated_date</col>
		</index>
	</table>

	<!-- ACL Section Table -->
	<table name="acl_sections">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="order_value" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="hidden" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="value_acl_sections">
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="hidden_acl_sections">
			<col>hidden</col>
		</index>
	</table>
	<sql>
		<descr>SQL to be executed only to insert default rows</descr>
		<query>
			DELETE FROM acl_sections WHERE id=1 AND value='system'
		</query>
		<query>
			INSERT INTO acl_sections (id,value,order_value,name) VALUES (1,'system',1,'System')
		</query>
		<query>
			DELETE FROM acl_sections WHERE id=2 AND value='user'
		</query>
		<query>
			INSERT INTO acl_sections (id,value,order_value,name) VALUES (2,'user',2,'User')
		</query>
	</sql>

	<!-- ACO Table -->
	<table name="aco">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="section_value" type="C" size="240">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="value" type="C" size="240">
			<NOTNULL/>
		</field>
		<field name="order_value" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="255">
			<NOTNULL/>
		</field>
		<field name="hidden" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="section_value_value_aco">
			<col>section_value</col>
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="hidden_aco">
			<col>hidden</col>
		</index>
	</table>

	<!-- ACL to ACO Map Table -->
	<table name="aco_map">
		<field name="acl_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="section_value" type="C" size="230">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
			<KEY/>
		</field>
	</table>

	<!-- ACO Section Table -->
	<table name="aco_sections">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="order_value" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="hidden" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="value_aco_sections">
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="hidden_aco_sections">
			<col>hidden</col>
		</index>
	</table>

	<!-- ARO Table -->
	<table name="aro">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="section_value" type="C" size="240">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="value" type="C" size="240">
			<NOTNULL/>
		</field>
		<field name="order_value" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="255">
			<NOTNULL/>
		</field>
		<field name="hidden" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="section_value_value_aro">
			<col>section_value</col>
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="hidden_aro">
			<col>hidden</col>
		</index>
	</table>

	<!-- ACL to ARO Map Table -->
	<table name="aro_map">
		<field name="acl_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="section_value" type="C" size="230">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
			<KEY/>
		</field>
	</table>

	<!-- ARO Section Table -->
	<table name="aro_sections">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="order_value" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="hidden" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="value_aro_sections">
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="hidden_aro_sections">
			<col>hidden</col>
		</index>
	</table>

	<!-- AXO Table -->
	<table name="axo">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="section_value" type="C" size="240">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="value" type="C" size="240">
			<NOTNULL/>
		</field>
		<field name="order_value" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="255">
			<NOTNULL/>
		</field>
		<field name="hidden" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="section_value_value_axo">
			<col>section_value</col>
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="hidden_axo">
			<col>hidden</col>
		</index>
	</table>

	<!-- ACL to AXO Map Table -->
	<table name="axo_map">
		<field name="acl_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="section_value" type="C" size="230">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
			<KEY/>
		</field>
	</table>

	<!-- AXO Section Table -->
	<table name="axo_sections">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="value" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="order_value" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="230">
			<NOTNULL/>
		</field>
		<field name="hidden" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		
		<index name="value_axo_sections">
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="hidden_axo_sections">
			<col>hidden</col>
		</index>
	</table>

	<!-- ARO Group Table -->
	<table name="aro_groups">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="parent_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="lft" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="rgt" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="255">
			<NOTNULL/>
		</field>
		<field name="value" type="C" size="255">
			<NOTNULL/>
			<KEY/>
		</field>
		
		<index name="parent_id_aro_groups">
			<col>parent_id</col>
		</index>
		<index name="value_aro_groups">
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="lft_rgt_aro_groups">
			<col>lft</col>
			<col>rgt</col>
		</index>
	</table>

	<!-- ARO to ARO Group Map Table -->
	<table name="groups_aro_map">
		<field name="group_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="aro_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<index name="aro_id">
			<descr>Index on aro_id</descr>
			<col>aro_id</col>
		</index>
	</table>

	<!-- ACL to ARO Group Map Table -->
	<table name="aro_groups_map">
		<field name="acl_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="group_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
	</table>

	<!-- AXO Group Table -->
	<table name="axo_groups">
		<field name="id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="parent_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="lft" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="rgt" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
		</field>
		<field name="name" type="C" size="255">
			<NOTNULL/>
		</field>
		<field name="value" type="C" size="255">
			<NOTNULL/>
			<KEY/>
		</field>
		
		<index name="parent_id_axo_groups">
			<col>parent_id</col>
		</index>
		<index name="value_axo_groups">
			<col>value</col>
			<UNIQUE/>
		</index>
		<index name="lft_rgt_axo_groups">
			<col>lft</col>
			<col>rgt</col>
		</index>
	</table>

	<!-- AXO to AXO Group Map Table -->
	<table name="groups_axo_map">
		<field name="group_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="axo_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<index name="axo_id">
			<descr>Index on axo_id</descr>
			<col>axo_id</col>
		</index>
	</table>

	<!-- ACL to AXO Group Map Table -->
	<table name="axo_groups_map">
		<field name="acl_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
		<field name="group_id" type="I">
			<DEFAULT value="0"/>
			<NOTNULL/>
			<KEY/>
		</field>
	</table>
</schema>
