<?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.1.0.1">
	<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->columnExists('issue_galleys', 'views');" />
		<code function="removeReviewEntries" />
		<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');" />
		<data file="dbscripts/xml/upgrade/3.0.0_preupdate_commentsToEditor.xml" condition="return $installer->columnExists('submissions', 'comments_to_ed');" />
		<code function="concatenateIntoAbout" />
		<code function="concatenateIntoMasthead" />
	</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>

	<upgrade minversion="2.4.0.0" maxversion="3.0.9.9">
		<data file="dbscripts/xml/upgrade/3.1.0_preupdate_review_assignments.xml" condition="return $installer->columnExists('review_assignments', 'cancelled');" />
		<data file="dbscripts/xml/upgrade/3.1.0_preupdate_notes.xml" condition="return $installer->columnExists('notes', 'file_id');" />
		<data file="dbscripts/xml/upgrade/3.1.0_preupdate_payments.xml" condition="return $installer->columnExists('completed_payments', 'journal_id');" />
	</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/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" />
	<schema file="lib/pkp/xml/schema/navigationMenus.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">
		<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_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="installDefaultGenres" />
		<code function="migrateArticleMetadata" />
		<data file="dbscripts/xml/upgrade/3.0.0_update.xml" />
		<code function="clearDataCache" />
		<code function="migrateUserRoles" />
		<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>

	<upgrade minversion="3.0.0.0" maxversion="3.0.9.9">
		<code function="installEmailTemplate" key="PASSWORD_RESET" locales="ca_ES,cs_CZ,da_DK,de_DE,en_US,es_ES,eu_ES,fi_FI,fr_CA,hr_HR,id_ID,it_IT,nb_NO,nl_NL,pt_BR,pt_PT,ru_RU,sv_SE,tr_TR,uk_UA,zh_CN" />
		<data file="dbscripts/xml/upgrade/3.1.0_update_a.xml" />
		<code function="fixGenreIdInFileNames" />
		<code function="repairKeywordsAndSubjects" />
		<code function="enabledSitePlugins" />
		<code function="moveCSSFiles" />
		<code function="repairSuppFilesFilestage" />
	</upgrade>

	<upgrade minversion="2.4.0.0" maxversion="3.0.9.9">
		<!--  the order of the next two lines is important -->
		<code function="moveReviewerFiles" />
		<code function="fixAuthorGroup" />
		<data file="dbscripts/xml/upgrade/3.0.0_reviewer_files.xml" />
		<code function="removeCancelledReviewAssignments" condition="return $installer->tableExists('review_assignments_tmp');" />
		<data file="dbscripts/xml/upgrade/3.1.0_notifications.xml" />
		<data file="dbscripts/xml/upgrade/3.1.0_notes.xml" condition="return $installer->tableExists('notes_tmp');" />
		<data file="dbscripts/xml/upgrade/3.1.0_galley_settings.xml" condition="return $installer->tableExists('article_galley_settings');" />
		<data file="dbscripts/xml/upgrade/3.1.0_update.xml" />
		<code function="repairImageAssociations" condition="return $installer->tableExists('submission_html_galley_images');" />
		<code function="installEmailTemplate" key="EDITOR_DECISION_INITIAL_DECLINE" locales="en_US" />
		<code function="installEmailTemplate" key="EDITOR_RECOMMENDATION" locales="en_US" />
		<code function="installDefaultNavigationMenus" />
		<note file="docs/release-notes/README-3.1.0" />
	</upgrade>

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