<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE schema SYSTEM "../../lib/pkp/dtd/xmlSchema.dtd">

<!--
  * omp_schema.xml
  *
  * Copyright (c) 2014-2021 Simon Fraser University
  * Copyright (c) 2003-2021 John Willinsky
  * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
  *
  * OMP database schema in XML.
  * XML-BASED DESCRIPTORS ARE DEPRECATED AND SHOULD NOT BE EDITED.
  -->

<schema version="0.2">
	<!--
	  *
	  * TABLE identification_codes
	  *
	  -->
	<table name="identification_codes">
		<field name="identification_code_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="publication_format_id" type="I8">
			<NOTNULL />
		</field>
		<field name="code" type="C2" size="40">
			<NOTNULL />
		</field>
		<field name="value" type="C2" size="255">
			<NOTNULL />
		</field>
		<index name="identification_codes_key">
			<col>identification_code_id</col>
			<col>publication_format_id</col>
			<col>code</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE publication_dates
	  *
	  -->
	<table name="publication_dates">
		<field name="publication_date_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="publication_format_id" type="I8">
			<NOTNULL />
		</field>
		<field name="role" type="C2" size="40">
			<NOTNULL />
		</field>
		<field name="date_format" type="C2" size="40">
			<NOTNULL />
		</field>
		<field name="date" type="C2" size="255">
			<NOTNULL />
		</field>
		<index name="format_publication_dates_pkey">
			<col>publication_date_id</col>
			<col>publication_format_id</col>
			<col>role</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE sales_rights
	  *
	  -->
	<table name="sales_rights">
		<field name="sales_rights_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="publication_format_id" type="I8">
			<NOTNULL />
		</field>
		<field name="type" type="C2" size="40">
			<NOTNULL />
		</field>
		<!--  ROW is 'rest of world'. ROW sales types have no territories assigned to them -->
		<field name="row_setting" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="countries_included" type="X"/>
		<field name="countries_excluded" type="X"/>
		<field name="regions_included" type="X"/>
		<field name="regions_excluded" type="X"/>
		<index name="format_sales_rights_pkey">
			<col>sales_rights_id</col>
			<col>publication_format_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE markets
	  *
	  -->
	<table name="markets">
		<field name="market_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="publication_format_id" type="I8">
			<NOTNULL />
		</field>
		<field name="countries_included" type="X"/>
		<field name="countries_excluded" type="X"/>
		<field name="regions_included" type="X"/>
		<field name="regions_excluded" type="X"/>
		<field name="market_date_role" type="C2" size="40">
			<NOTNULL />
		</field>
		<field name="market_date_format" type="C2" size="40">
			<NOTNULL />
		</field>
		<field name="market_date" type="C2" size="255">
			<NOTNULL />
		</field>
		<field name="price" type="C2" size="255"/>
		<field name="discount" type="C2" size="255"/>
		<field name="price_type_code" type="C2" size="255"/>
		<field name="currency_code" type="C2" size="255"/>
		<field name="tax_rate_code" type="C2" size="255"/>
		<field name="tax_type_code" type="C2" size="255"/>
		<field name="agent_id" type="I8" />
		<field name="supplier_id" type="I8" />
		<index name="format_markets_pkey">
			<col>market_id</col>
			<col>publication_format_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE representatives
	  *
	  -->
	<table name="representatives">
		<field name="representative_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="submission_id" type="I8">
			<NOTNULL />
		</field>
		<field name="role" type="C2" size="40">
			<NOTNULL />
		</field>
		<field name="representative_id_type" type="C2" size="255"/>
		<field name="representative_id_value" type="C2" size="255"/>
		<field name="name" type="C2" size="255"/>
		<field name="phone" type="C2" size="255"/>
		<field name="email" type="C2" size="255"/>
		<field name="url" type="C2" size="2047"/>
		<field name="is_supplier" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="1" />
		</field>
		<index name="format_representatives_pkey">
			<col>representative_id</col>
			<col>submission_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE features
	  *
	  -->
	<table name="features">
		<field name="submission_id" type="I8">
			<NOTNULL />
		</field>
		<field name="assoc_type" type="I8">
			<NOTNULL />
		</field>
		<field name="assoc_id" type="I8">
			<NOTNULL />
		</field>
		<field name="seq" type="I8">
			<NOTNULL />
		</field>
		<index name="press_features_pkey">
			<col>assoc_type</col>
			<col>assoc_id</col>
			<col>submission_id</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE new_releases
	  *
	  -->
	<table name="new_releases">
		<field name="submission_id" type="I8">
			<NOTNULL />
		</field>
		<field name="assoc_type" type="I8">
			<NOTNULL />
		</field>
		<field name="assoc_id" type="I8">
			<NOTNULL />
		</field>
		<index name="new_releases_pkey">
			<col>assoc_type</col>
			<col>assoc_id</col>
			<col>submission_id</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE series
	  *
	  -->
	<table name="series">
		<field name="series_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="press_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="review_form_id" type="I8" />
		<field name="seq" type="F">
			<!-- NOTNULL not included for the sake of 1.1 upgrade, which didn't include this column -->
			<DEFAULT VALUE="0"/>
		</field>
		<field name="featured" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="editor_restricted" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="path" type="C2" size="255">
			<NOTNULL />
		</field>
		<field name="image" type="X"/>
		<field name="is_inactive" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Press series.</descr>
		<index name="series_press_id">
			<col>press_id</col>
		</index>
		<index name="series_path">
			<col>press_id</col>
			<col>path</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE series_settings
	  *
	  -->
	<table name="series_settings">
		<field name="series_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="14">
			<NOTNULL />
			<DEFAULT VALUE=""/>
		</field>
		<field name="setting_name" type="C2" size="255">
			<NOTNULL />
		</field>
		<field name="setting_value" type="X"/>
		<field name="setting_type" type="C2" size="6">
			<NOTNULL/>
			<descr>(bool|int|float|string|object)</descr>
		</field>
		<descr>Series-specific settings</descr>
		<index name="series_settings_pkey">
			<col>series_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE series_categories
	  *
	  -->
	<table name="series_categories">
		<field name="series_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="category_id" type="I8">
			<NOTNULL/>
		</field>
		<descr>Associations for categories within a series.</descr>
		<index name="series_categories_id">
			<col>series_id</col>
			<col>category_id</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE publications
	  *
	  -->
	<table name="publications">
		<field name="publication_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="date_published" type="D"/>
		<field name="last_modified" type="T"/>
		<field name="locale" type="C2" size="14"/>
		<field name="primary_contact_id" type="I8" />
		<field name="publication_date_type" type="C2" size="32">
			<DEFAULT VALUE="pub"/>
		</field>
		<field name="publication_type" type="C2" size="32">
			<DEFAULT VALUE="publication"/><!-- PUBLICATION_TYPE_PUBLICATION -->
		</field>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="series_id" type="I8" />
		<field name="series_position" type="C2" size="255" />
		<field name="submission_id" type="I8">
			<NOTNULL />
		</field>
		<field name="status" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/><!-- STATUS_QUEUED -->
		</field>
		<field name="url_path" type="C2" size="64" />
		<field name="version" type="I8" />
		<descr>Publications</descr>
		<index name="publications_submission_id">
			<col>submission_id</col>
		</index>
		<index name="publications_section_id">
			<col>series_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE publication_formats
	  *
	  -->
	<table name="publication_formats">
		<field name="publication_format_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="publication_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="submission_id" type="I8">
			<!-- DEPRECATED: Held over for the OJS 2.x to 3. upgrade process pkp/pkp-lib#3572 -->
		</field>
		<field name="physical_format" type="I1">
			<DEFAULT VALUE="1"/>
		</field>
		<field name="entry_key" type="C2" size="64"/>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="file_size" type="C2" size="255"/>
		<field name="front_matter" type="C2" size="255"/>
		<field name="back_matter" type="C2" size="255"/>
		<field name="height" type="C2" size="255"/>
		<field name="height_unit_code" type="C2" size="255"/>
		<field name="width" type="C2" size="255"/>
		<field name="width_unit_code" type="C2" size="255"/>
		<field name="thickness" type="C2" size="255"/>
		<field name="thickness_unit_code" type="C2" size="255"/>
		<field name="weight" type="C2" size="255"/>
		<field name="weight_unit_code" type="C2" size="255"/>
		<field name="product_composition_code" type="C2" size="255"/>
		<field name="product_form_detail_code" type="C2" size="255"/>
		<field name="country_manufacture_code" type="C2" size="255" />
		<field name="imprint" type="C2" size="255"/>
		<field name="product_availability_code" type="C2" size="255"/>
		<field name="technical_protection_code" type="C2" size="255"/>
		<field name="returnable_indicator_code" type="C2" size="255"/>
		<field name="remote_url" type="C2" size="2047"/>
		<field name="url_path" type="C2" size="64" />
		<field name="is_approved" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="0" />
		</field>
		<field name="is_available" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="0" />
		</field>
		<descr>Publication formats assigned to published submissions</descr>
		<index name="publication_format_submission_id">
			<col>submission_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE publication_format_settings
	  *
	  -->
	<table name="publication_format_settings">
		<field name="publication_format_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="14">
			<NOTNULL />
			<DEFAULT VALUE=""/>
		</field>
		<field name="setting_name" type="C2" size="255">
			<NOTNULL />
		</field>
		<field name="setting_value" type="X"/>
		<field name="setting_type" type="C2" size="6">
			<NOTNULL/>
			<descr>(bool|int|float|string|object)</descr>
		</field>
		<descr>Publication Format metadata.</descr>
		<index name="publication_format_id_key">
			<col>publication_format_id</col>
		</index>
		<index name="publication_format_settings_pkey">
			<col>publication_format_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE submission_chapters
	  *
	  -->
	<table name="submission_chapters">
		<field name="chapter_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="primary_contact_id" type="I8" />
		<field name="publication_id" type="I8">
			<NOTNULL />
		</field>
		<field name="seq" type="F">
			<NOTNULL />
			<DEFAULT VALUE="0"/>
		</field>
		<index name="chapters_chapter_id">
			<col>chapter_id</col>
		</index>
		<index name="chapters_publication_id">
			<col>publication_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE submission_chapter_settings
	  *
	  -->
	<table name="submission_chapter_settings">
		<field name="chapter_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="14">
			<NOTNULL />
			<DEFAULT VALUE=""/>
		</field>
		<field name="setting_name" type="C2" size="255">
			<NOTNULL />
		</field>
		<field name="setting_value" type="X"/>
		<field name="setting_type" type="C2" size="6">
			<NOTNULL/>
			<descr>(bool|int|float|string|object)</descr>
		</field>
		<descr>Language dependent monograph chapter metadata.</descr>
		<index name="submission_chapter_settings_chapter_id">
			<col>chapter_id</col>
		</index>
		<index name="submission_chapter_settings_pkey">
			<col>chapter_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE submission_chapter_authors
	  *
	  -->
	<table name="submission_chapter_authors">
		<field name="author_id" type="I8">
			<NOTNULL />
		</field>
		<field name="chapter_id" type="I8">
			<NOTNULL />
		</field>
		<field name="primary_contact" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="seq" type="F">
			<NOTNULL />
			<DEFAULT VALUE="0"/>
		</field>
		<index name="chapter_authors_pkey">
			<col>author_id</col>
			<col>chapter_id</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE presses
	  *
	  -->
	<table name="presses">
		<field name="press_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="path" type="C2" size="32">
			<NOTNULL/>
		</field>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="primary_locale" type="C2" size="14">
			<NOTNULL/>
		</field>
		<field name="enabled" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<descr>Presses and basic press settings.</descr>
		<index name="press_path">
			<col>path</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE press_settings
	  *
	  -->
	<table name="press_settings">
		<field name="press_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="locale" type="C2" size="14">
			<NOTNULL/>
			<DEFAULT VALUE=""/>
		</field>
		<field name="setting_name" type="C2" size="255">
			<NOTNULL/>
		</field>
		<field name="setting_value" type="X"/>
		<field name="setting_type" type="C2" size="6"/>
		<descr>Press settings.</descr>
		<index name="press_settings_press_id">
			<col>press_id</col>
		</index>
		<index name="press_settings_pkey">
			<col>press_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE spotlights
	  *
	  -->
	<table name="spotlights">
		<field name="spotlight_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="assoc_type" type="I2">
			<NOTNULL/>
		</field>
		<field name="assoc_id" type="I2">
			<NOTNULL/>
		</field>
		<field name="press_id" type="I8">
			<NOTNULL/>
		</field>
		<descr>Spotlights</descr>
		<index name="spotlights_assoc">
			<col>assoc_type</col>
			<col>assoc_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE spotlight_settings
	  *
	  -->
	<table name="spotlight_settings">
		<field name="spotlight_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="14">
			<NOTNULL />
			<DEFAULT VALUE=""/>
		</field>
		<field name="setting_name" type="C2" size="255">
			<NOTNULL />
		</field>
		<field name="setting_value" type="X"/>
		<field name="setting_type" type="C2" size="6">
			<NOTNULL/>
			<descr>(bool|int|float|string|object|date)</descr>
		</field>
		<descr>Spotlight metadata.</descr>
		<index name="spotlight_settings_id">
			<col>spotlight_id</col>
		</index>
		<index name="spotlight_settings_pkey">
			<col>spotlight_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE queued_payments
	  *
	  -->
	<table name="queued_payments">
		<field name="queued_payment_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="date_created" type="T">
			<NOTNULL/>
		</field>
		<field name="date_modified" type="T">
			<NOTNULL/>
		</field>
		<field name="expiry_date" type="D" />
		<field name="payment_data" type="X" />
		<descr>Logs queued (unfulfilled) payments.</descr>
	</table>

	<!--
	  *
	  * TABLE completed_payments
	  *
	  -->
	<table name="completed_payments">
		<field name="completed_payment_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="timestamp" type="T">
			<NOTNULL/>
		</field>
		<field name="payment_type" type="I8">
			<NOTNULL/>
		</field>
		<field name="context_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="user_id" type="I8" />
		<!-- NOTE: assoc_id NOT numeric to incorporate file idents -->
		<field name="assoc_id" type="C2" size="16" />
		<field name="amount" type="F">
			<NOTNULL/>
		</field>
		<field name="currency_code_alpha" type="C2" size="3" />
		<field name="payment_method_plugin_name" type="C2" size="80" />
		<descr>Logs completed (fulfilled) payments.</descr>
	</table>
</schema>
