<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE install SYSTEM "../../lib/pkp/dtd/install.dtd">
<!--
  * upgrade.xml
  *
  * Copyright (c) 2014-2017 Simon Fraser University
  * Copyright (c) 2003-2017 John Willinsky
  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  *
  * Upgrade descriptor file.
  *
  -->

<install version="3.0.2.0">
	<upgrade minversion="2.0.0.0" maxversion="2.3.9.9">
		<!-- OJS < 2.4.0 to 3.0 upgrade unsupported -->
		<code function="abort" message="installer.unsupportedUpgradeError" />
	</upgrade>

	<upgrade minversion="2.9.8.9" maxversion="2.9.9.9">
		<!-- OJS 3.0 alpha or beta to 3.0 upgrade unsupported -->
		<code function="abort" message="installer.unsupportedUpgradeError" />
	</upgrade>

	<upgrade minversion="2.4.0.0" maxversion="2.4.9.9">
		<code function="syncSeriesAssocType" />
		<data file="dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics.xml" condition="return $installer->columnExists('article_galleys', 'views');" />
		<data file="dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics2.xml" condition="return $installer->tableExists('issue_galleys');" />
		<data file="dbscripts/xml/upgrade/3.0.0_preupdate.xml" condition="return $installer->columnExists('edit_decisions', 'article_id');" />	
		<data file="dbscripts/xml/upgrade/3.0.0_adaptTimedViews.xml" condition="return $installer->tableExists('timed_views_log');" />
		<data file="dbscripts/xml/upgrade/3.0.0_adaptReferrals.xml" condition="return $installer->tableExists('referrals');" />
		<data file="dbscripts/xml/upgrade/3.0.0_adaptBooksForReview.xml" condition="return $installer->tableExists('books_for_review');" />
		<data file="dbscripts/xml/upgrade/remove_timed_views_bots.xml" condition="return $installer->tableExists('timed_views_log');" />
		<code function="migrateCounterPluginUsageStatistics" condition="return $installer->tableExists('counter_monthly_log');" />
		<code function="migrateTimedViewsUsageStatistics" condition="return $installer->tableExists('timed_views_log');" />
		<code function="migrateDefaultUsageStatistics" condition="return $installer->tableExists('article_galleys_stats_migration');" />
		<data file="dbscripts/xml/upgrade/2.4.0_postUsageStatsMigration.xml" condition="return $installer->tableExists('article_galleys_stats_migration');" />
		<data file="dbscripts/xml/upgrade/2.4.0_postUsageStatsMigration2.xml" condition="return $installer->tableExists('issue_galleys_stats_migration');" />
		<data file="dbscripts/xml/upgrade/2.4.0_postCounterMigration.xml" condition="return $installer->tableExists('counter_monthly_log');" />
		<data file="dbscripts/xml/upgrade/2.4.0_postTimedViewsMigration.xml" condition="return $installer->tableExists('timed_views_log');" />
		<data file="dbscripts/xml/upgrade/3.0.0_preupdate_commentsToEditor.xml" condition="return $installer->columnExists('submissions', 'comments_to_ed');" />
	</upgrade>

	<upgrade minversion="3.0.0.0" maxversion="3.0.1.9">
		<data file="dbscripts/xml/upgrade/3.0.0_preupdate_commentsToEditor.xml" condition="return $installer->columnExists('submissions', 'comments_to_ed');" />
	</upgrade>
	
	<!-- PKP schema components -->
	<schema file="lib/pkp/xml/schema/common.xml" />
	<schema file="lib/pkp/xml/schema/log.xml" />
	<schema file="lib/pkp/xml/schema/announcements.xml" />
	<schema file="lib/pkp/xml/schema/scheduledTasks.xml" />
	<schema file="lib/pkp/xml/schema/temporaryFiles.xml" />
	<schema file="lib/pkp/xml/schema/metadata.xml" />
	<schema file="lib/pkp/xml/schema/reviews.xml" />
	<schema file="lib/pkp/xml/schema/reviewForms.xml" />
	<schema file="lib/pkp/xml/schema/controlledVocab.xml" />
	<schema file="lib/pkp/xml/schema/submissions.xml" />
	<schema file="lib/pkp/xml/schema/submissionFiles.xml" />
	<schema file="lib/pkp/xml/schema/notes.xml" />
	<schema file="lib/pkp/xml/schema/views.xml" />
	<schema file="lib/pkp/xml/schema/genres.xml" />
	<schema file="lib/pkp/xml/schema/gifts.xml" />
	<schema file="lib/pkp/xml/schema/mutex.xml" />
	<schema file="lib/pkp/xml/schema/tombstone.xml" />
	<schema file="lib/pkp/xml/schema/rolesAndUserGroups.xml" />
	<schema file="lib/pkp/xml/schema/metrics.xml" />
	<schema file="lib/pkp/xml/schema/views.xml" />
	<schema file="lib/pkp/xml/schema/libraryFiles.xml" />

	<!-- OJS schema -->
	<schema file="dbscripts/xml/ojs_schema.xml" />

	<!-- CLOB/Text indexes handled differently for MySQL and PostgreSQL -->
	<data file="dbscripts/xml/indexes.xml" />

	<upgrade minversion="2.4.0.0" maxversion="2.4.9.9">
		<data file="dbscripts/xml/upgrade/3.0.0_change_assoc_type.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_change_assoc_type_metrics.xml" condition="return $installer->tableExists('metrics');" />
		<data file="dbscripts/xml/upgrade/3.0.0_settings.xml" />
		<code function="migrateArticleMetadata" />
		<data file="dbscripts/xml/upgrade/3.0.0_update.xml" />
		<code function="clearDataCache" />
		<code function="migrateUserRoles" />
		<code function="installDefaultGenres" />
		<code function="fixReviewForms" />
		<code function="htmlifyEmailTemplates" />
		<note file="docs/release-notes/README-BEACON" />
		<code function="installEmailTemplate" key="NOTIFICATION_CENTER_DEFAULT" locales="en_US" />
		<code function="installEmailTemplate" key="REVIEW_REQUEST_REMIND_AUTO" locales="en_US" />
		<code function="installEmailTemplate" key="REVIEW_REQUEST_REMIND_AUTO_ONECLICK" locales="en_US" />
		<code function="installEmailTemplate" key="EDITOR_DECISION_SEND_TO_EXTERNAL" locales="en_US" />
		<code function="installEmailTemplate" key="EDITOR_DECISION_SEND_TO_PRODUCTION" locales="en_US" />
		<code function="installEmailTemplate" key="SUBMISSION_ACK_NOT_USER" locales="en_US,ca_ES,es_ES,fr_CA,pt_BR" />
		<data file="dbscripts/xml/upgrade/3.0.0_scheduledTasks.xml" />
		<code function="localizeCustomBlockSettings" />
		<code function="convertEditorDecisionNotes" />
		<code function="convertQueries" />
		<code function="migrateFiles" />
		<code function="convertSupplementaryFiles" />
		<code function="setFileUploader" />
		<code function="setFileName" />
		<data file="dbscripts/xml/upgrade/3.0.0_postupdate.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_pubId_settings.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_postupgrade_galley_files.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_postupgrade_metrics.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_issue_settings.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_submission_settings.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_review_method.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_edit_decisions.xml" />
		<code function="convertCommentsToEditor" condition="return $installer->tableExists('submissions_tmp');" />
		<note file="docs/release-notes/README-3.0" />
		<note file="docs/release-notes/README-3.0.1" />
	</upgrade>

	<upgrade minversion="3.0.0.0" maxversion="3.0.0.9">
		<code function="setFileUploader" />
		<code function="setFileName" />
		<data file="dbscripts/xml/upgrade/3.0.1_update.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_postupgrade_galley_files.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_postupgrade_metrics.xml" />
		<code function="localizeIssueCoverImages" />
		<code function="localizeArticleCoverImages" />
		<data file="dbscripts/xml/upgrade/3.0.0_issue_settings.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_submission_settings.xml" />
		<code function="installEmailTemplate" key="SUBMISSION_ACK_NOT_USER" locales="en_US,ca_ES,es_ES,fr_CA,pt_BR" />
		<data file="dbscripts/xml/upgrade/3.0.0_review_method.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_stage_assignments.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_edit_decisions.xml" />
		<code function="convertCommentsToEditor" condition="return $installer->tableExists('submissions_tmp');" />
		<note file="docs/release-notes/README-3.0.1" />
	</upgrade>

	<upgrade minversion="3.0.1.0" maxversion="3.0.1.9">
		<data file="dbscripts/xml/upgrade/3.0.0_review_method.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_stage_assignments.xml" />
		<data file="dbscripts/xml/upgrade/3.0.0_edit_decisions.xml" />
		<code function="clearCssCache" />
		<code function="convertCommentsToEditor" condition="return $installer->tableExists('submissions_tmp');" />
	</upgrade>

	<upgrade minversion="2.4.0.0" maxversion="3.0.1.9">
		<data file="dbscripts/xml/upgrade/3.0.2_update.xml" />
		<note file="docs/release-notes/README-3.0.2" />
	</upgrade>

	<!-- update plugin configuration - should be done as the final upgrade task -->
	<code function="addPluginVersions" />
</install>
