SET QUOTED_IDENTIFIER ON

GO

-- ============================================================================
-- Trend Display page (issue #338)
-- ============================================================================
-- SEC permission for the read proxy + per-page flag seed.
-- Convention (matches every other DBRevampEnabled.* setting in this project):
--   '1'         → route to the new MILL.* SP
--   '0' / NULL  → route to the legacy RFAC.* SP  (default during pre-cutover)
-- ============================================================================

EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetTrendDisplayDataWebProxy', 'Admin Profile', 'admin';
GO

EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRecentBilletsInFlight', 'Admin Profile', 'admin';
GO

IF NOT EXISTS (
    SELECT 1 FROM UTL.catSettings
    WHERE SettingName = 'Mill.DBRevampEnabled.TrendDisplay'
)
    EXEC UTL.SetSetting
        @OldName     = 'Mill.DBRevampEnabled.TrendDisplay',
        @NewName     = 'Mill.DBRevampEnabled.TrendDisplay',
        @Value       = '0',
        @Description = 'Routes the Trend Display page proxy (issue #338). 1 = new MILL implementation, 0/NULL = legacy RFAC.';
GO
