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

<install version="3.3.0.13">
	<code function="checkPhpVersion" />

	<!-- there are some column and table name changes that need to occur first. -->
	<upgrade minversion="0.9.9.0" maxversion="1.0.9.0">
		<!-- Upgrade prior versions to 1.1.0.0 -->
		<code function="syncSeriesAssocType" />
		<data file="dbscripts/xml/upgrade/1.1.0.0_preupdate.xml" condition="return $installer->columnExists('plugin_settings', 'press_id');" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="1.1.9.0">
		<!-- Upgrade prior versions to 1.2.0.0 -->
		<data file="dbscripts/xml/upgrade/1.2.0.0_preupdate.xml" condition="return $installer->tableExists('series_editors');" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="1.2.0.9">
		<data file="dbscripts/xml/upgrade/3.1.0_preupdate_commentsToEditor.xml" condition="return $installer->columnExists('submissions', 'comments_to_ed');" />
		<data file="dbscripts/xml/upgrade/3.1.0_preupdate.xml" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="3.1.0.9">
		<data file="dbscripts/xml/upgrade/3.1.1_preupdate_citations.xml" condition="return $installer->columnExists('citations', 'assoc_id');" />
		<data file="dbscripts/xml/upgrade/3.1.1_preupdate_payments.xml" condition="return $installer->columnExists('completed_payments', 'press_id');" />
	</upgrade>
	<upgrade minversion="0.9.9.0" maxversion="3.1.9.9">
		<data file="dbscripts/xml/upgrade/3.1.2_preupdate_user_author_names.xml" condition="return $installer->columnExists('users', 'first_name');" />
		<data file="dbscripts/xml/upgrade/3.1.2_preupdate_chapters.xml" condition="return $installer->columnExists('submission_chapters', 'chapter_seq');" />
		<data file="dbscripts/xml/upgrade/3.1.2_preupdate_categories.xml" condition="return $installer->columnExists('categories', 'press_id');" />
		<data file="dbscripts/xml/upgrade/3.1.2_preupdate_pub_id.xml" condition="return $installer->columnExists('published_submissions', 'pub_id');" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="3.1.9.9">
		<code function="migrateSubmissionCoverImages" />
		<data file="dbscripts/xml/upgrade/3.2.0_preupdate_email_templates.xml" />
		<data file="dbscripts/xml/upgrade/3.2.0_preupdate_versioning.xml" />
		<data file="dbscripts/xml/upgrade/3.2.0_preupdate_versioning_add_ps_seq.xml" condition="return !$installer->columnExists('temp_published_submissions', 'seq');" />
		<data file="dbscripts/xml/upgrade/3.2.0_preupdate_last_activity.xml" />
	</upgrade>

	<upgrade minversion="3.0.0.0" maxversion="3.1.9.9">
		<!-- Old schema syncs: These are deprecated! -->
		<schema file="lib/pkp/xml/schema/common.xml" />
		<schema file="lib/pkp/xml/schema/scheduledTasks.xml" />
		<schema file="lib/pkp/xml/schema/temporaryFiles.xml" />
		<schema file="lib/pkp/xml/schema/log.xml" />
		<schema file="lib/pkp/xml/schema/notes.xml" />
		<schema file="lib/pkp/xml/schema/controlledVocab.xml" />
		<schema file="lib/pkp/xml/schema/metadata.xml" />
		<schema file="lib/pkp/xml/schema/announcements.xml" />
		<schema file="lib/pkp/xml/schema/reviews.xml" />
		<schema file="lib/pkp/xml/schema/reviewForms.xml" />
		<schema file="lib/pkp/xml/schema/submissions.xml" />
		<schema file="lib/pkp/xml/schema/submissionFiles.xml" />
		<schema file="lib/pkp/xml/schema/tombstone.xml" />
		<schema file="lib/pkp/xml/schema/genres.xml" />
		<schema file="lib/pkp/xml/schema/libraryFiles.xml" />
		<schema file="lib/pkp/xml/schema/rolesAndUserGroups.xml" />
		<schema file="lib/pkp/xml/schema/views.xml" />
		<schema file="lib/pkp/xml/schema/metrics.xml" />
		<schema file="lib/pkp/xml/schema/navigationMenus.xml" />
		<schema file="lib/pkp/xml/schema/categories.xml" />
		<schema file="dbscripts/xml/omp_schema.xml" />
	</upgrade>

	<!-- Install default NavigationMenus -->
	<code function="installDefaultNavigationMenus" />
	<code function="migrateStaticPagesToNavigationMenuItems" />

	<upgrade minversion="0.9.9.0" maxversion="3.1.9.9">
		<code function="migrateUserAndAuthorNames" condition="return $installer->tableExists('users_tmp');" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="1.0.9.9">
		<!-- Upgrade prior versions to 1.1.0.0 -->
		<data file="dbscripts/xml/upgrade/1.1.0.0_update.xml" />
		<code function="fixFilenames" />
		<code function="enableDefaultTheme" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="1.0.0.0">
		<!--
		 - Upgrade from 1.0.0.0 (excluding 1.0.1.0, which was
		 - briefly in the omp-stable-1_0 branch).
		 -->
		<data file="dbscripts/xml/upgrade/1.1.0.0_update2.xml" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="1.1.0.9">
		<code function="fixAuthorSettings" /><!-- Bug #8663 -->
		<data file="dbscripts/xml/upgrade/1.1.1.0_update.xml" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="1.1.9.9">
		<code function="htmlifyEmailTemplates" /><!-- Bug #8929 -->
		<data file="dbscripts/xml/upgrade/1.2.0.0_update.xml" />
		<code function="convertQueries" />
		<code function="installEmailTemplate" key="REVIEW_REQUEST_REMIND_AUTO" locales="de_DE,el_GR,en_US,es_ES,fr_CA,pt_BR" />
		<code function="installEmailTemplate" key="REVIEW_REQUEST_REMIND_AUTO_ONECLICK" locales="de_DE,el_GR,en_US,es_ES,fr_CA,pt_BR" />
		<data file="dbscripts/xml/upgrade/1.2.0.0_postupdate.xml" />
		<note file="docs/release-notes/README-BEACON" />
		<code function="convertCommentsToEditor" condition="return $installer->tableExists('submissions_tmp');" />
	</upgrade>

	<upgrade minversion="1.2.0.0" maxversion="1.2.0.9">
		<code function="fixQueriesAssocTypes" />
		<code function="convertCommentsToEditor" condition="return $installer->tableExists('submissions_tmp');" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="1.2.0.9">
		<data file="dbscripts/xml/upgrade/3.1.0_update.xml" />
		<note file="docs/release-notes/README-3.1.0" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="3.1.0.9">
		<data file="dbscripts/xml/upgrade/3.1.1_notifications.xml" />
		<data file="dbscripts/xml/upgrade/3.1.1_update.xml" />
		<code function="installEmailTemplate" key="EDITOR_DECISION_INITIAL_DECLINE" locales="en_US" />
		<code function="installEmailTemplate" key="EDITOR_RECOMMENDATION" locales="en_US" />
		<code function="clearDataCache" />
		<note file="docs/release-notes/README-3.1.1" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="3.1.1.9">
		<data file="dbscripts/xml/upgrade/3.1.2_update.xml" />
		<note file="docs/release-notes/README-3.1.2" />
	</upgrade>

	<upgrade minversion="0.9.9.0" maxversion="3.1.9.9">
		<data file="dbscripts/xml/upgrade/3.2.0_update.xml" />
		<data file="dbscripts/xml/upgrade/3.2.0_stylesheet.xml" />
		<data file="dbscripts/xml/upgrade/3.2.0_navigation_menu_items_locale_change.xml" />
		<code function="migrateSiteLocales" />
		<code function="migrateSidebarBlocks" />
		<code function="migrateMetadataSettings" />
		<code function="installEmailTemplate" key="REVIEW_REINSTATE" locales="en_US" />
		<code function="changeUserRolesAndStageAssignmentsForStagePermitSubmissionEdit" />
		<data file="dbscripts/xml/upgrade/3.2.0_versioning.xml" />
		<data file="dbscripts/xml/upgrade/3.2.0_last_activity.xml" />
		<code function="setStatsEmailSettings" />
		<code function="fixLibraryFiles" />
		<code function="installEmailTemplate" key="STATISTICS_REPORT_NOTIFICATION" locales="ca_ES,da_DK,en_US,es_ES,pt_BR,pt_PT" />
		<note file="docs/release-notes/README-3.2.0" />
	</upgrade>

	<upgrade minversion="2.4.0.0" maxversion="3.2.0.9">
		<data file="dbscripts/xml/upgrade/3.2.1_update.xml" />
		<code function="installEmailTemplate" key="ANNOUNCEMENT" locales="ca_ES,da_DK,en_US,es_ES,pt_BR" />
		<migration class="lib.pkp.classes.migration.upgrade.PKPv3_2_1SubeditorCategoriesMigration" />
		<note file="docs/release-notes/README-3.2.1" />
	</upgrade>

	<upgrade minversion="3.0.0.0" maxversion="3.2.9.9">
		<migration class="lib.pkp.classes.migration.upgrade.PKPv3_3_0UpgradeMigration" />
		<migration class="classes.migration.upgrade.OMPv3_3_0UpgradeMigration" />
		<note file="docs/release-notes/README-3.3.0" />
	</upgrade>

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