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

LrClassicIndexDefinitions.lua

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

ADOBE CONFIDENTIAL
------------------
Copyright 2023 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.sqlite.index_store
local WFRxIndexStoreSchema = require 'WFRxIndexStoreSchema'

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

local LrClassicIndexDefinitions = {}
	
--============================================================================--

local sqlitePageSize = 4096

local indexStoreSchema = WFRxIndexStoreSchema( sqlitePageSize )

indexStoreSchema:addDatabaseInitRoutine( require 'WFSQLiteSetLogicImp'.registerSetModule )

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

local function getIndexSchemaGenerators(  )
	return { 
		'DesktopCommonIndexDefinitions',
		'NmbExternalDevelopSettings',
		'WFCatBinaryUploader',
		'WFCatConflictResolver',
		'WFCatCollaboration',
		'WFCatCollaborator',
		'LrFavoritesIndexDefinitions',
		'LrCommentsIndexDefinitions',
		'WFCatDelete',
		'WFCatErrorHandler',
		'WFCatIdleDownloader',
		'WFCatImportDuplicateFiles',
		'WFCatSortHandler',
		'WFCatStaleBinaryRemover',
		'WFCatStorage',
		'WFCatSyncStatus',
		'LrClassicSyncStatus',
		'WFCatSearchByAlbum', -- albums table, used by LrC
		
		-- classic don't use the following table, but indexStoreSchemaVersionList will need to check the existing of those index tables 
		'NmbFileMover',
		'NmbPresetDocumentProcessor',
		'NmbSimpleDocStoreUpdater',
		'WFCatVolumeAgentQueryHelper',
		'WFCatVersions',
		'WFCatStacks',
		}
end

--------------------------------------------------------------------------------
local function generateIndexSchema( theIndexStoreSchema )

	local indexSchemaGenerators = getIndexSchemaGenerators()
	
	for _, generator in pairs( indexSchemaGenerators ) do
		require ( generator ).generateIndexSchema( theIndexStoreSchema )
	end
	
end

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

generateIndexSchema ( indexStoreSchema )

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

local WFConfiguration = require 'WFConfiguration'

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

if WFConfiguration.Nimbus.Nmb5582InvalidOriginals then

	require 'WFCatInvalidOriginalHandler'.generateIndexSchema( indexStoreSchema )

end

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

LrClassicIndexDefinitions.indexStoreSchema = indexStoreSchema

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

return LrClassicIndexDefinitions
