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

<!--
  * ojs_schema.xml
  *
  * Copyright (c) 2013-2016 Simon Fraser University Library
  * Copyright (c) 2003-2016 John Willinsky
  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  *
  * OJS database schema in XML.
  *
  -->

<schema version="0.2">

	<!--
	  *
	  * TABLE journals
	  *
	  -->
	<table name="journals">
		<field name="journal_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="5">
			<NOTNULL/>
		</field>
		<field name="enabled" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<descr>Journals and basic journal settings.</descr>
		<index name="journals_path">
			<col>path</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE journal_settings
	  *
	  -->
	<table name="journal_settings">
		<field name="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="locale" type="C2" size="5">
			<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>Journal settings.</descr>
		<index name="journal_settings_journal_id">
			<col>journal_id</col>
		</index>
		<index name="journal_settings_pkey">
			<col>journal_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE plugin_settings
	  *
	  -->
	<table name="plugin_settings">
		<field name="plugin_name" type="C2" size="80">
			<NOTNULL/>
		</field>
		<field name="locale" type="C2" size="5">
			<NOTNULL/>
			<DEFAULT VALUE=""/>
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="setting_name" type="C2" size="80">
			<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>Plugin settings.</descr>
		<index name="plugin_settings_plugin_name">
			<col>plugin_name</col>
		</index>
		<index name="plugin_settings_pkey">
			<col>plugin_name</col>
			<col>locale</col>
			<col>journal_id</col>
			<col>setting_name</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE roles
	  *
	  -->
	<table name="roles">
		<field name="journal_id" type="I8">
			<NOTNULL />
		</field>
		<field name="user_id" type="I8">
			<NOTNULL />
		</field>
		<field name="role_id" type="I8">
			<NOTNULL />
		</field>
		<descr>User roles in journals.</descr>
		<index name="roles_journal_id">
			<col>journal_id</col>
		</index>
		<index name="roles_user_id">
			<col>user_id</col>
		</index>
		<index name="roles_role_id">
			<col>role_id</col>
		</index>
		<index name="roles_pkey">
			<col>journal_id</col>
			<col>user_id</col>
			<col>role_id</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE sections
	  *
	  -->
	<table name="sections">
		<field name="section_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="review_form_id" type="I8" />
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="editor_restricted" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="meta_indexed" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="meta_reviewed" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<field name="abstracts_not_required" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="hide_title" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="hide_author" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="hide_about" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="disable_comments" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="abstract_word_count" type="I8" />
		<descr>Journal sections.</descr>
		<index name="sections_journal_id">
			<col>journal_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE section_settings
	  *
	  -->
	<table name="section_settings">
		<field name="section_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="5">
			<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>Section-specific settings</descr>
		<index name="section_settings_section_id">
			<col>section_id</col>
		</index>
		<index name="section_settings_pkey">
			<col>section_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE section_editors
	  *
	  -->
	<table name="section_editors">
		<field name="journal_id" type="I8">
			<NOTNULL />
		</field>
		<field name="section_id" type="I8">
			<NOTNULL />
		</field>
		<field name="user_id" type="I8">
			<NOTNULL />
		</field>
		<field name="can_edit" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="1" />
		</field>
		<field name="can_review" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="1" />
		</field>
		<descr>Assignments of section editors to sections.</descr>
		<index name="section_editors_journal_id">
			<col>journal_id</col>
		</index>
		<index name="section_editors_section_id">
			<col>section_id</col>
		</index>
		<index name="section_editors_user_id">
			<col>user_id</col>
		</index>
		<index name="section_editors_pkey">
			<col>journal_id</col>
			<col>section_id</col>
			<col>user_id</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE issues
	  *
	  -->
	<table name="issues">
		<field name="issue_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL />
		</field>
		<field name="volume" type="I2"/>
		<field name="number" type="C2" size="10" />
		<field name="year" type="I2"/>
		<field name="published" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="0" />
		</field>
		<field name="current" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="0" />
		</field>
		<field name="date_published" type="T" />
		<field name="date_notified" type="T" />
		<field name="last_modified" type="T" />
		<field name="access_status" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="1" />
		</field>
		<field name="open_access_date" type="T" />
		<field name="show_volume" type="I1">
			<NOTNULL />
			<DEFAULT VALUE="0" />
		</field>
		<field name="show_number" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="show_year" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="show_title" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="style_file_name" type="C2" size="90"/>
		<field name="original_style_file_name" type="C2" size="255"/>
		<descr>Journal issues.</descr>
		<index name="issues_journal_id">
			<col>journal_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE issue_settings
	  *
	  -->
	<table name="issue_settings">
		<field name="issue_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="5">
			<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/>
		</field>
		<descr>Locale-specific issue data</descr>
		<index name="issue_settings_issue_id">
			<col>issue_id</col>
		</index>
		<index name="issue_settings_pkey">
			<col>issue_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE />
		</index>
	</table>

	<!--
	  *
	  * TABLE issue_galleys
	  *
	  -->
	<table name="issue_galleys">
		<field name="galley_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="locale" type="C2" size="5"/>
		<field name="issue_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="file_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="label" type="C2" size="32"/>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Issue galleys.</descr>
		<index name="issue_galleys_issue_id">
			<col>issue_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE issue_galley_settings
	  *
	  -->
	<table name="issue_galley_settings">
		<field name="galley_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="5">
			<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>Issue galley metadata.</descr>
		<index name="issue_galley_settings_galley_id">
			<col>galley_id</col>
		</index>
		<index name="issue_galley_settings_pkey">
			<col>galley_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE issue_files
	  *
	  -->
	<table name="issue_files">
		<field name="file_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="issue_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="file_name" type="C2" size="90">
			<NOTNULL/>
		</field>
		<field name="file_type" type="C2" size="255">
			<NOTNULL/>
		</field>
		<field name="file_size" type="I8">
			<NOTNULL/>
		</field>
		<field name="content_type" type="I8">
			<NOTNULL/>
		</field>
		<field name="original_file_name" type="C2" size="127"/>
		<field name="date_uploaded" type="T">
			<NOTNULL/>
		</field>
		<field name="date_modified" type="T">
			<NOTNULL/>
		</field>
		<index name="issue_files_issue_id">
			<col>issue_id</col>
		</index>
	</table>

	<!--
	  * TABLE custom_issue_orders
	  *
	  -->
	<table name="custom_issue_orders">
		<field name="issue_id" type="I8">
			<NOTNULL />
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Custom sequencing information for journal issues, when available</descr>
		<index name="custom_issue_orders_pkey">
			<col>issue_id</col>
			<UNIQUE/>
		</index>
	</table>

	<table name="custom_section_orders">
		<field name="issue_id" type="I8">
			<NOTNULL />
		</field>
		<field name="section_id" type="I8">
			<NOTNULL />
		</field>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Custom sequencing information for journal sections by issue, when available.</descr>
		<index name="custom_section_orders_pkey">
			<col>issue_id</col>
			<col>section_id</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE articles
	  *
	  -->
	<table name="articles">
		<field name="article_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="locale" type="C2" size="5" />
		<field name="user_id" type="I8">
			<NOTNULL />
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL />
		</field>
		<field name="section_id" type="I8" />
		<field name="language" type="C2" size="10">
			<DEFAULT VALUE="en"/>
		</field>
		<field name="comments_to_ed" type="X"/>
		<field name="citations" type="X"/>
		<field name="date_submitted" type="T"/>
		<field name="last_modified" type="T"/>
		<field name="date_status_modified" type="T"/>
		<field name="status" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<field name="submission_progress" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<field name="current_round" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<field name="submission_file_id" type="I8"/>
		<field name="revised_file_id" type="I8"/>
		<field name="review_file_id" type="I8"/>
		<field name="editor_file_id" type="I8"/>
		<field name="pages" type="C2" size="255"/>
		<field name="fast_tracked" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="hide_author" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="comments_status" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Journal articles.</descr>
		<index name="articles_user_id">
			<col>user_id</col>
		</index>
		<index name="articles_journal_id">
			<col>journal_id</col>
		</index>
		<index name="articles_section_id">
			<col>section_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_settings
	  *
	  -->
	<table name="article_settings">
		<field name="article_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="5">
			<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>Journal article metadata.</descr>
		<index name="article_settings_article_id">
			<col>article_id</col>
		</index>
		<index name="article_settings_pkey">
			<col>article_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE published_articles
	  *
	  -->
	<table name="published_articles">
		<field name="published_article_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="article_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="issue_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="date_published" type="T"/>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="access_status" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Journal articles.</descr>
		<index name="published_articles_article_id">
			<col>article_id</col>
			<UNIQUE/>
		</index>
		<index name="published_articles_issue_id">
			<col>issue_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_files
	  *
	  -->
	<table name="article_files">
		<field name="file_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="revision" type="I8">
			<KEY />
		</field>
		<field name="source_file_id" type="I8" />
		<field name="source_revision" type="I8" />
		<field name="article_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="file_name" type="C2" size="90">
			<NOTNULL/>
		</field>
		<field name="file_type" type="C2" size="255">
			<NOTNULL/>
		</field>
		<field name="file_size" type="I8">
			<NOTNULL/>
		</field>
		<field name="original_file_name" type="C2" size="127"/>
		<field name="file_stage" type="I8">
			<NOTNULL/>
		</field>
		<field name="viewable" type="I1" />
		<field name="date_uploaded" type="T">
			<NOTNULL/>
		</field>
		<field name="date_modified" type="T">
			<NOTNULL/>
		</field>
		<field name="round" type="I1">
			<NOTNULL/>
		</field>
		<field name="assoc_id" type="I8"/>
		<descr>Files associated with articles. Includes submission files, supplementary files, etc.</descr>
		<index name="article_files_article_id">
			<col>article_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_supplementary_files
	  *
	  -->
	<table name="article_supplementary_files">
		<field name="supp_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="file_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="article_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="type" type="C2" size="255"/>
		<field name="language" type="C2" size="10"/>
		<field name="remote_url" type="C2" size="255"/>
		<field name="date_created" type="D"/>
		<field name="show_reviewers" type="I1">
			<DEFAULT VALUE="0"/>
		</field>
		<field name="date_submitted" type="T">
			<NOTNULL/>
		</field>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Supplementary files attached to articles.</descr>
		<index name="article_supplementary_files_file_id">
			<col>file_id</col>
		</index>
		<index name="article_supplementary_files_article_id">
			<col>article_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_supp_file_settings
	  *
	  -->
	<table name="article_supp_file_settings">
		<field name="supp_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="5">
			<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>Article supplementary file metadata.</descr>
		<index name="article_supp_file_settings_supp_id">
			<col>supp_id</col>
		</index>
		<index name="article_supp_file_settings_pkey">
			<col>supp_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE edit_assignments
	  *
	  -->
	<table name="edit_assignments">
		<field name="edit_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="article_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="editor_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="can_edit" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<field name="can_review" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<field name="date_assigned" type="T"/>
		<field name="date_notified" type="T"/>
		<field name="date_underway" type="T"/>
		<descr>Editing assignments.</descr>
		<index name="edit_assignments_article_id">
			<col>article_id</col>
		</index>
		<index name="edit_assignments_editor_id">
			<col>editor_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE edit_decisions
	  *
	  -->
	<table name="edit_decisions">
		<field name="edit_decision_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="article_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="round" type="I1">
			<NOTNULL/>
		</field>
		<field name="editor_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="decision" type="I1">
			<NOTNULL/>
		</field>
		<field name="date_decided" type="T">
			<NOTNULL/>
		</field>
		<descr>Editor decisions.</descr>
		<index name="edit_decisions_article_id">
			<col>article_id</col>
		</index>
		<index name="edit_decisions_editor_id">
			<col>editor_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_galleys
	  *
	  -->
	<table name="article_galleys">
		<field name="galley_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="locale" type="C2" size="5"/>
		<field name="article_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="file_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="label" type="C2" size="32"/>
		<field name="html_galley" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="style_file_id" type="I8"/>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="remote_url" type="C2" size="255" />
		<descr>Article galleys.</descr>
		<index name="article_galleys_article_id">
			<col>article_id</col>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_galley_settings
	  *
	  -->
	<table name="article_galley_settings">
		<field name="galley_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="5">
			<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>Article galley metadata.</descr>
		<index name="article_galley_settings_galley_id">
			<col>galley_id</col>
		</index>
		<index name="article_galley_settings_pkey">
			<col>galley_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_html_galley_images
	  *
	  -->
	<table name="article_html_galley_images">
		<field name="galley_id" type="I8">
			<NOTNULL />
		</field>
		<field name="file_id" type="I8">
			<NOTNULL />
		</field>
		<descr>Images associated with an article HTML galley.</descr>
		<index name="article_html_galley_images_pkey">
			<col>galley_id</col>
			<col>file_id</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	  *
	  * TABLE article_comments
	  *
	  -->
	<table name="article_comments">
		<field name="comment_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="comment_type" type="I8"/>
		<field name="role_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="article_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="assoc_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="author_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="comment_title" type="C2" size="255">
			<NOTNULL/>
		</field>
		<field name="comments" type="X"/>
		<field name="date_posted" type="T"/>
		<field name="date_modified" type="T"/>
		<field name="viewable" type="I1" />
		<descr>Comments posted on articles.</descr>
		<index name="article_comments_article_id">
			<col>article_id</col>
		</index>
	</table>

	<!--
	 *
	 * TABLE article_search_keyword_list
	 *
	 -->
	<table name="article_search_keyword_list">
		<field name="keyword_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="keyword_text" type="C2" size="60">
			<NOTNULL/>
		</field>
		<descr>List of all keywords.</descr>
		<index name="article_search_keyword_text">
			<col>keyword_text</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	 *
	 * TABLE article_search_objects
	 *
	 -->
	<table name="article_search_objects">
		<field name="object_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="article_id" type="I8">
			<NOTNULL />
		</field>
		<field name="type" type="I4">
			<NOTNULL />
			<descr>Type of item. E.g., abstract, fulltext, etc.</descr>
		</field>
		<field name="assoc_id" type="I8">
			<descr>Optional ID of an associated record (e.g., a file_id)</descr>
		</field>
		<descr>Indexed objects.</descr>
	</table>

	<!--
	 *
	 * TABLE article_search_object_keywords
	 *
	 -->
	<table name="article_search_object_keywords">
		<field name="object_id" type="I8">
			<NOTNULL />
		</field>
		<field name="keyword_id" type="I8">
			<NOTNULL />
		</field>
		<field name="pos" type="I4">
			<NOTNULL />
			<descr>Word position of the keyword in the object.</descr>
		</field>
		<descr>Keyword occurrences for each indexed object.</descr>
		<index name="article_search_object_keywords_keyword_id">
			<col>keyword_id</col>
		</index>
		<index name="article_search_object_keywords_pkey">
			<col>object_id</col>
			<col>pos</col>
			<UNIQUE />
		</index>
	</table>

	<!-- Reading Tools Tables -->

	<!--
	 *
	 * TABLE rt_versions
	 *
	 -->
	<table name="rt_versions">
		<field name="version_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="version_key" type="C2" size="40">
			<NOTNULL/>
		</field>
		<field name="locale" type="C2" size="5">
			<DEFAULT VALUE="en_US"/>
		</field>
		<field name="title" type="C2" size="120">
			<NOTNULL/>
		</field>
		<field name="description" type="X"/>
		<descr>Reading Tools versions.</descr>
		<index name="rt_versions_journal_id">
			<col>journal_id</col>
		</index>
		<index name="rt_versions_version_key">
			<col>version_key</col>
		</index>
	</table>

	<!--
	 *
	 * TABLE rt_contexts
	 *
	 -->
	<table name="rt_contexts">
		<field name="context_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="version_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="title" type="C2" size="120">
			<NOTNULL/>
		</field>
		<field name="abbrev" type="C2" size="32">
			<NOTNULL/>
		</field>
		<field name="description" type="X"/>
		<field name="cited_by" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="author_terms" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="define_terms" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="geo_terms" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Reading Tools contexts (within versions).</descr>
		<index name="rt_contexts_version_id">
			<col>version_id</col>
		</index>
	</table>

	<!--
	 *
	 * TABLE rt_searches
	 *
	 -->
	<table name="rt_searches">
		<field name="search_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="context_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="title" type="C2" size="120">
			<NOTNULL/>
		</field>
		<field name="description" type="X"/>
		<field name="url" type="X"/>
		<field name="search_url" type="X"/>
		<field name="search_post" type="X"/>
		<field name="seq" type="F">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<descr>Reading Tools searches (within contexts).</descr>
		<index name="rt_searches_context_id">
			<col>context_id</col>
		</index>
	</table>

	<!--
	 *
	 * TABLE subscription_types
	 *
	 -->
	<table name="subscription_types">
		<field name="type_id" type="I8">
			<KEY />
			<AUTOINCREMENT />
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="cost" type="F">
			<NOTNULL/>
		</field>
		<field name="currency_code_alpha" type="C2" size="3">
			<NOTNULL/>
		</field>
		<field name="non_expiring" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="duration" type="I2">
		</field>
		<field name="format" type="I2">
			<NOTNULL/>
		</field>
		<field name="institutional" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="membership" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="0"/>
		</field>
		<field name="disable_public_display" type="I1">
			<NOTNULL/>
		</field>
		<field name="seq" type="F">
			<NOTNULL/>
		</field>
		<descr>Subscription types.</descr>
	</table>

	<!--
	  *
	  * TABLE subscription_type_settings
	  *
	  -->
	<table name="subscription_type_settings">
		<field name="type_id" type="I8">
			<NOTNULL />
		</field>
		<field name="locale" type="C2" size="5">
			<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/>
		</field>
		<descr>Locale-specific subscription type data</descr>
		<index name="subscription_type_settings_type_id">
			<col>type_id</col>
		</index>
		<index name="subscription_type_settings_pkey">
			<col>type_id</col>
			<col>locale</col>
			<col>setting_name</col>
			<UNIQUE/>
		</index>
	</table>

	<!--
	 *
	 * TABLE subscriptions
	 *
	 -->
	<table name="subscriptions">
		<field name="subscription_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="user_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="type_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="date_start" type="D">
		</field>
		<field name="date_end" type="T">
		</field>
		<field name="date_reminded_before" type="T">
		</field>
		<field name="date_reminded_after" type="T">
		</field>
		<field name="status" type="I1">
			<NOTNULL/>
			<DEFAULT VALUE="1"/>
		</field>
		<field name="membership" type="C2" size="40"/>
		<field name="reference_number" type="C2" size="40"/>
		<field name="notes" type="X"/>
		<descr>Journal subscriptions.</descr>
	</table>

	<!--
	 *
	 * TABLE institutional_subscriptions
	 *
	 -->
	<table name="institutional_subscriptions">
		<field name="institutional_subscription_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="subscription_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="institution_name" type="C2" size="255">
			<NOTNULL/>
		</field>
		<field name="mailing_address" type="C2" size="255"/>
		<field name="domain" type="C2" size="255"/>
		<descr>Journal institutional subscriptions.</descr>
		<index name="institutional_subscriptions_subscription_id">
			<col>subscription_id</col>
		</index>
		<index name="institutional_subscriptions_domain">
			<col>domain</col>
		</index>
	</table>

	<!--
	 *
	 * TABLE institutional_subscription_ip
	 *
	 -->
	<table name="institutional_subscription_ip">
		<field name="institutional_subscription_ip_id" type="I8">
			<KEY />
			<AUTOINCREMENT/>
		</field>
		<field name="subscription_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="ip_string" type="C2" size="40">
			<NOTNULL/>
		</field>
		<field name="ip_start" type="I8">
			<NOTNULL/>
		</field>
		<field name="ip_end" type="I8">
		</field>
		<descr>Journal institutional subscription IPs and IP ranges.</descr>
		<index name="institutional_subscription_ip_subscription_id">
			<col>subscription_id</col>
		</index>
		<index name="institutional_subscription_ip_start">
			<col>ip_start</col>
		</index>
		<index name="institutional_subscription_ip_end">
			<col>ip_end</col>
		</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="journal_id" type="I8">
			<NOTNULL/>
		</field>
		<field name="user_id" type="I8" />
		<field name="assoc_id" type="I8" />
		<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>
