--[[----------------------------------------------------------------------------

WFRxIndexStoreSchemaVersionList.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2020 Adobe
All Rights Reserved.

NOTICE: All information contained herein is, and remains
the property of Adobe and its suppliers, if any. The intellectual
and technical concepts contained herein are proprietary to Adobe
and its suppliers and are protected by all applicable intellectual
property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from Adobe.

------------------------------------------------------------------------------]]

	-- WF.core.utils
local WFArguments = require 'WFArguments'
local WFCapabilities = require 'WFCapabilities'
local WFPlatformInfo = require 'WFPlatformInfo'

local WFArguments_check = assert( WFArguments.check )

--============================================================================--

-- @mark WFRxIndexStoreSchemaVersionList namespace

local WFRxIndexStoreSchemaVersionList = {}

--------------------------------------------------------------------------------

-- The indexStore schema version list definition.
-- sequence: a sequential list of schema versions. The version list based reindexer will
--           reindex all documents which are defined by sequences > the current sequence
--           If the current schema is not in list, fall back to hash based reindexing,
--           sequence = 0, if in this list, simply disables the fall back to hash based reindexing.
-- platforms: list of platforms affected by this sequence.
--            allowed: Nimbus(Desktop), Classic, iOS, Android, MacOSX, Windows and the composites SharedDesktop, Mobile, All
--            Note: the lookup is case sensitive!
--            Note: If you only reindex a subset of platforms, you may need an additional
--                entry in the opt-out list.
-- tables:    list of tables affected

-- Example:
--	{
--		{
--			sequence = 0,
--		},
--		{
--			sequence = 1,
--			platforms = { "Mobile", },
--			tables = { "coreInfo", "album", "album_asset" }
--		}
--	}

--==============================================================================

--@mark Schema Version List Opt-In

--------------------------------------------------------------------------------

-- "Desktop" and "Nimbus" refer to LrD. For new entries, please use Nimbus as
-- the platform identifier.
--
-- "SharedDesktop" refers to both Nimbus and Classic
--
-- "Classic" refers to Classic

local _indexStoreSchemaVersionList = {
	{
		sequence = 0, -- wf/releases/3.3
	},
	{
		sequence = 1,
		platforms = { "Desktop", },
		tables = { "asset_sync_status_ui", "assetPathsAndInfo", "presetsAndProfiles" }
		-- https://git.corp.adobe.com/lua/wf/pull/3290/commits/2cfc47bd4caf3b88c0d6d04a7db5ffe69a0b3ca5
		-- https://git.corp.adobe.com/lua/wf/pull/3290/commits/dc44a83f7f56d0e276505e4f0963e53b419215ae
	},
	{
		sequence = 2,
		platforms = { "Mobile", },
		tables = { "album_asset", "albums", "blocked_uploads", "cacheReferences", "profileRegistration",
					"presetsProfiles", "trashAssets" }
		-- https://git.corp.adobe.com/lua/wf/pull/3290/commits/dc44a83f7f56d0e276505e4f0963e53b419215ae
	},
	{
		sequence = 3,
		platforms = { "Android", },
		tables = { "CustomCameraProfiles", "coreMD5" }
		-- https://git.corp.adobe.com/lua/wf/pull/3290/commits/dc44a83f7f56d0e276505e4f0963e53b419215ae
	},
	{
		sequence = 4,
		platforms = { "All", },
		tables = { "space_album" }
		-- https://git.corp.adobe.com/lua/wf/pull/3290/commits/dc44a83f7f56d0e276505e4f0963e53b419215ae
	},
	{
		sequence = 5,
		platforms = { "Desktop", },
		tables = { "cameras", "keywords", "locations" }
		-- https://git.corp.adobe.com/lua/wf/pull/3332/commits/0cdb2163bd6b84d140b751eb3b2c735c49caabe2
	},
	{
		sequence = 6,
		platforms = { "Desktop", },
		tables = { "asset_sync_status_ui" }
		-- https://git.corp.adobe.com/lua/wf/pull/3358/commits/9b5220328caddc5eb38e03bd13a674f6f25e2cb2
	},
	{
		sequence = 7,
		platforms = { "Mobile", },
		tables = { "coreInfo" }
		-- https://git.corp.adobe.com/lua/wf/pull/3358/commits/9b5220328caddc5eb38e03bd13a674f6f25e2cb2
	},
	{
		sequence = 8,
		platforms = { "All", },
		tables = { "needsBinaryUpload" }
		-- https://git.corp.adobe.com/lua/wf/pull/3379
	},
	{
		sequence = 9,
		platforms = { "Android", },
		tables = { "cacheReferences", "trashAssets" }
		-- https://git.corp.adobe.com/lua/wf/pull/3389
	},
	{
		sequence = 11,
		platforms = { "Desktop", },
		tables = { "simple_updates" }
		-- https://jira.corp.adobe.com/browse/WF-1730
	},
	{
		sequence = 12,
		platforms = { "All", },
		tables = { "purgeCandidates" }
		-- New Purge Agent
		-- https://jira.corp.adobe.com/browse/WF-1834
	},
	{
		sequence = 13,
		platforms = { "Mobile", },
		tables = { "cacheReferences" }
		-- New Purge Agent
		-- https://jira.corp.adobe.com/browse/WF-1834
	},
	{
		sequence = 14,
		platforms = { "All", },
		tables = { "purgeCandidates" }
		-- https://git.corp.adobe.com/lua/wf/pull/3675
	},
	{
		sequence = 15,
		platforms = { "Desktop", },
		tables = { "editedDate" }
		-- https://git.corp.adobe.com/lua/wf/pull/3621/commits/8951c5abb71fdd9046287c5f7286a97b7582323b
	},
	{
		sequence = 16,
		platforms = { "All", },
		tables = { "purgeCandidates" }
		-- https://git.corp.adobe.com/lua/wf/pull/3710
	},
	{
		sequence = 17,
		platforms = { "Desktop", },
		tables = { "localStatusAndOzStatus", "simple_updates" }
		-- https://git.corp.adobe.com/lua/wf/pull/3710
	},
	{
		sequence = 18,
		platforms = { "All", },
		tables = { "auxReferenceTracker" }
		-- https://git.corp.adobe.com/lua/wf/pull/3719
	},
	{
		sequence = 19,
		platforms = { "Mobile", },
		tables = { "renditionRevisions", "coreInfo" }
		-- https://git.corp.adobe.com/lua/wf/pull/3803
		-- https://git.corp.adobe.com/lua/wf/pull/3844
	},
	{
		sequence = 20,
		platforms = { "All", },
		tables = { "purgeCandidates" }
	},
	{
		sequence = 21,
		platforms = { "Desktop", },
		tables = { "asset_sync_status_ui", "localStatusAndOzStatus"  }
		-- https://jira.corp.adobe.com/browse/NMB-22994
		-- https://jira.corp.adobe.com/browse/NMB-21744
	},
	{
		sequence = 22,
		platforms = { "All", },
		tables = { "purgeCandidates" }
		-- https://git.corp.adobe.com/lua/wf/pull/3930
	},
	{
		sequence = 23,
		platforms = { "Desktop", },
		tables = { "albums" }
	},
	{
		sequence = 24,
		platforms = { "Mobile", },
		tables = { "coreInfo" }
		-- https://jira.corp.adobe.com/browse/WF-1842
	},
	{
		sequence = 25,
		platforms = { "Desktop", },
		tables = { "asset_sync_status_ui" }
		-- https://jira.corp.adobe.com/browse/WF-1842
	},
	{
		sequence = 26,
		platforms = { "Mobile", },
		tables = { "renditionRevisions" }
		-- https://git.corp.adobe.com/lua/wf/pull/4078
	},
	{
		sequence = 27,
		platforms = { "All", },
		tables = { "needsBinaryUpload" }
		-- https://git.corp.adobe.com/lua/wf/pull/4097
	},
	{
		sequence = 28,
		platforms = { "Desktop", },
		tables = { "localStatusAndOzStatus"  }
	},
	{
		sequence = 29,
		platforms = { "All", },
		tables = { "needsBinaryUpload"  }
	},
	{
		sequence = 30,
		platforms = { "All", },
		tables = { "needsBinaryUpload"  }
	},
	{
		sequence = 31,
		platforms = { "Desktop", },
		tables = { "localStatusAndOzStatus", "asset_sync_status_ui"  }
	},
	-- 32 : Entry Removed Due to Deleted Table
	{
		sequence = 33,
		platforms = { "Mobile", },
		tables = { "coreInfo", "versions" }
	},
	{
		sequence = 34,
		platforms = { "Desktop", },
		tables = { "asset_sync_status_ui" }
	},
	{
		sequence = 35,
		platforms = { "All", },
		tables = { "unconfirmedDeletions" }
	},
	{
		sequence = 36,
		platforms = { "All", },
		tables = { "purgeCandidates" }
	},
	{
		sequence = 37,
		platforms = { "Desktop", },
		tables = { "albums" }
		--https://git.corp.adobe.com/lua/wf/pull/4527
	},
	{
		sequence = 38,
		platforms = { "iOS", },
		tables = { "needsBinaryUpload" }
	},
	{
		sequence = 39,
		platforms = { "Desktop", },
		tables = { "importSource" }
		--https://git.corp.adobe.com/lua/wf/pull/4565
	},
	{
		sequence = 40,
		platforms = { "All", },
		tables = { "unconfirmedDeletions" }
	},
	{
		sequence = 41,
		platforms = { "Desktop", },
		tables = { "versions" }
		-- BYOCR work
	},
	{
		sequence = 42,
		platforms = { "Mobile", },
		tables = { "importSource" }
		--https://git.corp.adobe.com/lua/wf/pull/4565 again - reindexing oversight
	},
	{
		sequence = 43,
		platforms = { "Desktop", },
		tables = { "asset_sync_status_ui" }
		-- reindexing oversight
	},
	{
		sequence = 44,
		platforms = { "Desktop", },
		tables = { "asset_sync_status_ui" }
		-- https://git.corp.adobe.com/lua/wf/pull/4631
	},
	{
		sequence = 45,
		platforms = { "All", },
		tables = { "needsBinaryUpload" }
		-- https://git.corp.adobe.com/lua/wf/pull/4655
		-- https://jira.corp.adobe.com/browse/WF-2311
	},
	{
		sequence = 46,
		platforms = { "All", },
		tables = { "errors" }
		--https://git.corp.adobe.com/lua/wf/pull/4666
	},
	{
		sequence = 47,
		platforms = { "All", },
		tables = { "importSource" }
		--https://git.corp.adobe.com/lua/wf/pull/4737
	},
	{
		sequence = 48,
		platforms = { "All", },
		tables = { "needsBinaryUpload" }
		-- https://git.corp.adobe.com/lua/wf/pull/4759
		-- https://jira.corp.adobe.com/browse/WF-2358
	},
	{
		sequence = 49,
		platforms = { "All", },
		tables = { "needsBinaryUpload" }
		-- https://git.corp.adobe.com/lua/wf/pull/4770
		-- https://jira.corp.adobe.com/browse/WF-2326
	},
	{
		sequence = 50,
		platforms = { "Desktop", },
		tables = { "simple_updates" }
		-- Fix false positive InvalidLocalOriginal errors
		-- https://jira.corp.adobe.com/browse/NMB-25894
	},
	{
		sequence = 51,
		platforms = { "Mobile", },
		tables = { "coreInfo" }
		-- Update contentType number for jxl and Avif
		-- https://jira.corp.adobe.com/browse/WF-2379
	},
	{
		sequence = 52,
		platforms = { "All", },
		tables = { "needsBinaryUpload" }
		-- https://git.corp.adobe.com/lua/wf/pull/4909
		-- https://jira.corp.adobe.com/browse/WF-2416
	},
	{
		sequence = 53,
		platforms = { "All", },
		tables = {
			"needsBinaryUpload",
			"purgeCandidates",
		}
		-- https://git.corp.adobe.com/lua/wf/pull/4922
		-- https://jira.corp.adobe.com/browse/WF-2415
		-- change was mostly relating to binary upload, but WFFileSpec function
		-- getXmpDevelopLinkFromDocValue() got a behavior and name
		-- change to getXmpDevelopLinkAndSha256FromDocValue() which is called
		-- from WFCatIdleDownloader, WFCatVolumeAgentQueryHelper.lua and
		-- WFCatSyncStatus.lua so several tables impacted
	},
	{
		sequence = 54,
		platforms = { "Desktop", },
		tables = {
			"asset_sync_status_ui",
			"localStatusAndOzStatus",
		}
		-- same change as sequence 53, just asset_sync_status_ui and
		-- localStatusAndOzStatus are desktop only index tables so will
		-- get test errors (at least) if included for mobile platforms
		-- https://git.corp.adobe.com/lua/wf/pull/4922
		-- https://jira.corp.adobe.com/browse/WF-2415
	},
	{
		sequence = 55,
		platforms = { "All", },
		tables = {
			"needsBinaryUpload",
		}
		-- actually forgot to reindex in PR 4934 but that
		-- was the change that required the reindex. Change
		-- to function maybeEmitXmpDevelopUploadRecord() altering
		-- logic on whether version xmp_develop upload should
		-- use direct upload or not.
		-- https://git.corp.adobe.com/lua/wf/pull/4934
		-- https://jira.corp.adobe.com/browse/WF-2429
	},
	{
		sequence = 56,
		platforms = { "All", },
		tables = {
			"needsBinaryUpload",
		}
		-- Original fix for WF-2429 was specific to versions but
		-- in trying to repro the problem and confirm the fix with a client
		-- saw there was also a similar problem for assets that needed
		-- to be fixed which requires an additional reindex of this table.
		-- https://git.corp.adobe.com/lua/wf/pull/4944
		-- https://jira.corp.adobe.com/browse/WF-2429
	},
	{
		sequence = 57,
		platforms = { "Classic", },
		tables = {
			"albums",
		}
		-- Add customize albums table for classic
		-- https://jira.corp.adobe.com/browse/WF-2442
	},
	{
		sequence = 58,
		platforms = { "Classic", },
		tables = {
			"needsBinaryUpload",
		}
		-- WF-2526. Limit the reindex to Classic. Not necessary on other platforms.
		-- https://git.corp.adobe.com/lua/wf/pull/5125
	},
	{
		sequence = 59,
		platforms = { "Classic", },
		tables = {
			"classic_asset_sync_status",
		}
		-- WF-2526. Add missingBinaries column to classic_asset_sync_status to track 
		-- binaries missing from docValue
		-- https://jira.corp.adobe.com/browse/WF-2526
	},
	{
		sequence = 60,
		platforms = { "Desktop", "Mobile" },
		tables = {
			"docsToUpdate",
		}
		-- New table used by desktop, ios and android, not classic
		-- https://jira.corp.adobe.com/browse/WF-2507
	},
	{
		sequence = 61,
		platforms = { "All" },
		tables = {
			"needsBinaryUpload",
		}
		-- also as part of PR https://jira.corp.adobe.com/browse/WF-2507
		-- tweakd to logic used by map function for needsBinaryUpload.
	},
	{
		sequence = 62,
		platforms = { "Desktop" },
		tables = {
			"smart_albums",
		}
		-- New table used by desktop
		-- https://git.corp.adobe.com/lua/wf/pull/5151
	},
	{
		sequence = 63,
		platforms = { "All" },
		tables = {
			"importSource",
		}
		-- https://git.corp.adobe.com/lua/wf/pull/5196
	},
	{
		sequence = 64,
		platforms = { "All" },
		tables = {
			"auxReferenceTracker",
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5194
	},
	{
		sequence = 65,
		platforms = { "All" },
		tables = {
			"auxReferenceTracker",
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5210
	},
	{
		sequence = 66,
		platforms = { "SharedDesktop" },
		tables = {
			"asset_sync_status_ui",
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5255
	},
	{
		sequence = 67,
		platforms = { "Classic" },
		tables = {
			"classic_asset_sync_status",
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5255
	},
	{
		sequence = 68,
		platforms = { "SharedDesktop" },
		tables = {
			"asset_sync_status_ui",
			"localStatusAndOzStatus"
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5262
	},
	{
		sequence = 69,
		platforms = { "Nimbus" },
		tables = {
			"extensions",
		}
		-- New table used by Nimbus
		-- https://git.corp.adobe.com/lua/wf/pull/5261
	},
	{
		sequence = 70,
		platforms = { "All" },
		tables = {
			"trashAssets",
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5269
	},
	{
		sequence = 71,
		platforms = { "All" },
		tables = {
			"needsBinaryUpload",
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5289
		-- https://git.corp.adobe.com/lua/wf/pull/5298
	},
	{
		sequence = 72,
		platforms = { "SharedDesktop" },
		tables = {
			"simple_updates",
		},
		-- https://git.corp.adobe.com/lua/wf/pull/5368
	},
	{
		sequence = 73,
		platforms = { "Mobile", },
		tables = { "renditionRevisions" }
		-- https://git.corp.adobe.com/lua/wf/pull/5414
	},
	{
		sequence = 74,
		platforms = { "Mobile", },
		tables = { "coreInfo" }
		-- https://git.corp.adobe.com/lua/wf/pull/5429
		-- https://git.corp.adobe.com/lua/wf/pull/5432
	},
	{
		sequence = 75,
		platforms = { "SharedDesktop", },
		tables = { "assets" }
		-- https://git.corp.adobe.com/lua/wf/pull/5432
	},
	{
		sequence = 76,
		platforms = { "All", },
		tables = { "trashAssets" }
		-- https://git.corp.adobe.com/lua/wf/pull/5432
	},
	{
		sequence = 77,
		platforms = { "All", },
		tables = { 
			"auxReferenceTracker", 
			"purgeCandidates"
		}
		-- https://git.corp.adobe.com/lua/wf/pull/5441
	},
	{
		sequence = 78,
		platforms = { "All", },
		tables = { 
			"purgeCandidates"
		}
		-- https://git.corp.adobe.com/lua/wf/pull/5453
	},

}

--==============================================================================

--@mark Schema Version List Explicit Opt-Out

--------------------------------------------------------------------------------

-- The indexStore schema version list opt-out definition.
-- platforms: list of platforms we're opting out of reindexing for:
--            allowed: iOS, Android, MacOSX, Windows and the composites Desktop, Mobile, All
--            Note: the lookup is case sensitive!
--            Note: If you only opt-out for a subset of platforms, you may need an additional
--                entry in the schema version list.
-- tables: list of tables affected
-- why: a brief explanation of why a reindex is not required.

-- Example:
--	{
--		{
--			platforms = { "Mobile", },
--			tables = { "coreInfo", "album", "album_asset" }
--			why = "whitespace adjustments"
--		},
--		{
--			platforms = { "All", },
--			tables = { "versions" },
--			why = "non-functional code changes"
--		}
--	}

--==============================================================================

local _indexStoreSchemaVersionListOptOut = {
	-- wf/releases/6.0
	{
		platforms = { "Mobile", },
		tables = { "simple_updates" },
		why = "This is a desktop only table"
	},
	-- wf/releases/6.2
	{
		platforms = { "Desktop", },
		tables = { "project_albums", "assets" },
		why = "non-functional code changes"
	},
	-- Moving the definitions of project_albums and assets table into DesktopCommonIndexDefinitions.lua
	-- Because it's shared by nimbus and classic platform
	-- https://git.corp.adobe.com/lua/wf/pull/4848
	{
		platforms = { "Nimbus", },
		tables = {
			"albums",
		},
		why = "non-functional code changes"
		-- Add customize albums table for classic and does not change any behavior in nimbus
		-- https://jira.corp.adobe.com/browse/WF-2442
	},
	{
		platforms = { "SharedDesktop" },
		tables = {
			"localStatusAndOzStatus",
		},
		-- inlcude c2pa in localStatusAndOzStatus table but there isn't any c2pa in the system yet
		-- https://git.corp.adobe.com/lua/wf/pull/5187
	},	
}

--==============================================================================

local validPlatforms = {
	iOS = true,
	Android = true,
	MacOSX = true,
	Windows = true,
	Desktop = true,
	SharedDesktop = true,
	Nimbus = true,
	Classic = true,
	Mobile = true,
	All = true,
}

-------------------------------------------------------------------------------

local function sequenceAffectsThisPlatform( platforms )

	local platform = WFPlatformInfo.getOS()

	for _, v in ipairs( platforms ) do

		if validPlatforms[ v ] == nil then
			error( string.format( "WFRxIndexStoreSchemaVersionList: invalid platform specificer: %s", v ) )
		end

		if v == platform then
			return true
		end

		if WFPlatformInfo.isMobile() and v == "Mobile" then
			return true
		end

		if WFPlatformInfo.isNimbus() and ( v == "Desktop" or v == "Nimbus" ) then
			return true
		end
		
		if WFPlatformInfo.isDesktop and v == "SharedDesktop" then
			return true
		end
		
		if WFPlatformInfo.isClassic() and v == "Classic" then
			return true
		end
		
		if v == "All" then
			return true
		end
	end

	return false
end

-------------------------------------------------------------------------------

local function isInList( t, list )

	for _, v in ipairs( list ) do
		if v == t then
			return true
		end
	end

	return false

end

-------------------------------------------------------------------------------

local function addTables( tables, toBeReindexedTables, validTables )

	for _, t in ipairs( tables ) do

		if not isInList( t, validTables ) then
			error( string.format( "WFRxIndexStoreSchemaVersionList.addTables(): invalid table '%s' for this platform", t) )
		end

		if not isInList( t, toBeReindexedTables ) then
			toBeReindexedTables[ #toBeReindexedTables +1 ] = t
		end

	end

end

--------------------------------------------------------------------------------

function WFRxIndexStoreSchemaVersionList.getTablesToReindex( currentSequence, validTables )

	WFArguments_check( '?number', 'table')

	if not currentSequence then
		currentSequence = -1
	end

	local indexStoreSchemaVersionList = _indexStoreSchemaVersionList

	if WFPlatformInfo.isUnitTest() then

		-- Some index store unit tests use WFCapabilities to override the indexStoreSchemaVersionList
		-- defined in this file; this allows the tests to cover a wider array of reindexing scenarios.

		local WFMsgPack = require 'WFMsgPack'
		local WFCapabilities = require 'WFCapabilities'

		local maybeIndexStoreSchemaVersionListOverride = WFCapabilities.getCapability( 'WFRxIndexStoreTest.indexStoreSchemaVersionListOverride' )

		if maybeIndexStoreSchemaVersionListOverride then

			indexStoreSchemaVersionList = WFMsgPack.unpack( maybeIndexStoreSchemaVersionListOverride )

		else

			-- Default to an empty schema version list for unit tests.

			indexStoreSchemaVersionList = {
				{
					sequence = 0,
				}
			}

		end

	end

	if #indexStoreSchemaVersionList == 0 then
		error( "WFRxIndexStoreSchemaVersionList.getTablesToReindex(): invalid schema version list")
	end

	local lastSequence = -1

	local toBeReindexedTables = {}

	for _, v in ipairs( indexStoreSchemaVersionList ) do

		if type( v ) ~= 'table' then
			error( "WFRxIndexStoreSchemaVersionList.getTablesToReindex(): invalid schema version list, expected table" )
		end

		if type( v.sequence ) ~= 'number' or v.sequence <= lastSequence then
			error( "WFRxIndexStoreSchemaVersionList.getTablesToReindex(): invalid sequence" )
		end

		lastSequence = v.sequence

		if v.sequence > 0 then

			if type( v.platforms ) ~= 'table' or #v.platforms == 0 then
				error( "WFRxIndexStoreSchemaVersionList.getTablesToReindex(): invalid platforms" )
			end

			if type( v.tables) ~= 'table' or #v.tables == 0 then
				error( "WFRxIndexStoreSchemaVersionList.getTablesToReindex(): tables must be a list" )
			end

			if v.sequence > currentSequence then
				if sequenceAffectsThisPlatform( v.platforms ) then
					addTables( v.tables, toBeReindexedTables, validTables )
				end
			end

		end

	end

	local baseSequence = indexStoreSchemaVersionList[ 1 ].sequence

	if currentSequence < 0 or
			( baseSequence > currentSequence and baseSequence ~= 0 ) or
			currentSequence > lastSequence then

		return lastSequence, "hashBasedIndexing"
			-- currentSequence is no longer in list, fall back to hash based reindexing
			-- OR currentSequence is newer than the latest entry in the list. fall back.

	else

		return lastSequence, toBeReindexedTables

	end

end

--------------------------------------------------------------------------------

function WFRxIndexStoreSchemaVersionList.TEST_setSchemaVersionList( rxTest, schemaVersionList )

	WFArguments_check( 'table')

	local WFMsgPack = require 'WFMsgPack'

	WFCapabilities.setCapability( 'WFRxIndexStoreTest.indexStoreSchemaVersionListOverride', WFMsgPack.pack( schemaVersionList ) )

	rxTest:finally( function()
		WFCapabilities.setCapability( 'WFRxIndexStoreTest.indexStoreSchemaVersionListOverride', nil )
	end )

end

--------------------------------------------------------------------------------

function WFRxIndexStoreSchemaVersionList.affectsThisPlatform( platforms )

	return sequenceAffectsThisPlatform( platforms )

end

--------------------------------------------------------------------------------

function WFRxIndexStoreSchemaVersionList.getSchemaVersionList()

	return _indexStoreSchemaVersionList

end

--------------------------------------------------------------------------------

function WFRxIndexStoreSchemaVersionList.getSchemaVersionListOptOutList()

	return _indexStoreSchemaVersionListOptOut

end

--------------------------------------------------------------------------------

return WFRxIndexStoreSchemaVersionList
