

--  ------------  Generated from [/big2/11.0/Build80_SP24/cxunix/source/CommServer/Db/TblScript/APP_OpWindowRule.script] ---------- 


SET QUOTED_IDENTIFIER ON
SET NOCOUNT ON

-- ALLOW_COMMENTS_BELOW_HERE:

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

--                                                                      

--           Copyright (c) 1998  CommVault Systems, Inc.                

--                  All rights reserved.                                

--                                                                      

--                                                                   

--        This is unpublished proprietary source code of CommVault  

--        Systems, Inc. The copyright notice above does not evidence 

--        any actual or intended publication of such source code. 

-- ----------------------------------------------------------------------*/

-- rcsid[]="@(#)$Source: /cvs/cvsrepro/GX/vaultcx/Source/CommServer/Db/TblScript/APP_OpWindowRule.script,v $ $Id: APP_OpWindowRule.script,v 1.1.2.2.8.1 2021/06/10 03:15:05 nramalingam Exp $";

GO

SET QUOTED_IDENTIFIER ON

SET NOCOUNT ON

GO

DECLARE @nowTime    int =  DATEDIFF(second, '01/01/1970', GETUTCDATE())

DECLARE @transactionLogBackupUpg    VARCHAR(40) = 'CBD5F458-E967-4D1F-A054-53342ACB5291'

IF NOT EXISTS (SELECT 1 FROM GXUniqueSQLScriptExecTracking WHERE SqlScriptGUID = @transactionLogBackupUpg)

BEGIN

	--Set operation type Transaction log backup if Non Full Data Management is selected.

	UPDATE APP_OpWindowRule

		SET opType = opType | 0x2000 --0x2000 = OPERATION_TRANSACTION_LOG_BACKUP

	WHERE

		opType & 0x02 = 0x02 --0x02 = OPERATION_NON_FULL_DATA_PROTECTION
	INSERT INTO GXUniqueSQLScriptExecTracking(SqlScriptGUID, Name, Description, CreatedTime, CreatedRelId, ExpireTime, ExpireRelId)


VALUES (@transactionLogBackupUpg, 'transactionLogBackupUpg', 'Upgrade script to set transaction log backup if non full data protection is set.', @nowTime,  16, 0, (16 + 2))

END

--one time update to offset endtime by 60 seconds when its 11:59pm

DECLARE @offsetOperationWindoEndTimeGUID	VARCHAR(40) = 'A2A223C1-9C73-4E66-9C90-B5F07DB33A9F'

IF NOT EXISTS (SELECT 1 FROM GXUniqueSQLScriptExecTracking WHERE SqlScriptGUID = @offsetOperationWindoEndTimeGUID)

BEGIN

	UPDATE APP_OpWindowRule SET endtime = 86400 WHERE endtime = 86340
	INSERT INTO GXUniqueSQLScriptExecTracking(SqlScriptGUID, Name, Description, CreatedTime, CreatedRelId, ExpireTime, ExpireRelId)


VALUES (@offsetOperationWindoEndTimeGUID, 'OffsetOperationWindoEndTime', 'Upgrade script to offset endtime of Operation Window.', @nowTime,  16, 0, (16 + 2))

END

SET NOCOUNT OFF

GO

SET QUOTED_IDENTIFIER ON

GO
