SET QUOTED_IDENTIFIER ON

GO

BEGIN
-- Cost Centers
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetCostCenters', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertCostCenter', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveCostCenter', 'admin Profile', 'devops';

-- Operators
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetOperators', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertOperator', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveOperator', 'admin Profile', 'devops';

-- Suppliers
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetSuppliers', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertSupplier', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveSupplier', 'admin Profile', 'devops';

-- Roll Materials
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollMaterials', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertRollMaterial', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveRollMaterial', 'admin Profile', 'devops';

-- Roll Applications
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollApplications', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertRollApplication', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveRollApplication', 'admin Profile', 'devops';

-- Rolls Blank
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollBlanks', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertRollBlank', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveRollBlank', 'admin Profile', 'devops';

-- Roll Blank Attachments
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollBlankAttachments', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertRollBlankAttachment', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.DeleteRollBlankAttachment', 'admin Profile', 'devops';

-- Shared (used by Rolls Blank filters)
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetMillSizes', 'admin Profile', 'devops';

-- Product Types
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetProductTypes', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertProductType', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveProductType', 'admin Profile', 'devops';

-- Product Sizes
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetProductSizes', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertProductSize', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveProductSize', 'admin Profile', 'devops';

-- Product Changes
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetProductChanges', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertProductChanges', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveProductChange', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RecalculateProductChangesTime', 'admin Profile', 'devops';

-- Product Mill Setup
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetProductMillSetup', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertProductMillSetup', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveProductMillSetup', 'admin Profile', 'devops';

-- Shared (used by Products page)
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetStands', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetPassIds', 'admin Profile', 'devops';

-- Recipes
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRecipes', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRecipeStands', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpsertRecipe', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.RemoveRecipe', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.CreateRecipeEmpty', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.DuplicateRecipe', 'admin Profile', 'devops';

-- Mill Setup Proxy Procedures
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetPassChangeReasonsProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetProductTypesProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetProductSizesProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRecipesMetaProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollingMillSetupCampaignDataWebProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollingMillSetupStandsDataWebProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetCurrentDelayWebProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollingMillSetupLastBilletsDataWebProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetWorkOrdersProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollsetsProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.GetRollsProductionProxy', 'admin Profile', 'devops';

-- Mill Setup Mutation Proxy Procedures (currently hardcoded to new DB only)
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.StartCampaignProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.ChangePassProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.ChangeRollsetProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.ChangeWorkOrderProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.UpdateCampaignProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.ResetTemporalBilletsCountProxy', 'admin Profile', 'devops';
EXEC SEC.UpsertProcedureAndSetToProfile 'MILL.ValidatePassChangeProxy', 'admin Profile', 'devops';

UPDATE DEL.Delays SET IsMicroDelay = 0

-- Monitoring Jobs
EXEC [SYSTEM].[InitializeJob] @sProcedure = '[RBD].[ProcessAlertsHourlyJob]', @PeriodTime = 3600, @RestartAfterFailure = 1, @Enabled = 1;

END


