alter table PatchManagedDevice
	add WaitingForPatchDownload [bit] NOT NULL constraint PatchManagedDevice_WaitingForPatchDownload_DF default(0)
go

	ALTER TABLE PatchAgentConfiguration ADD 
		ScheduleType		TINYINT		null,
		ScheduleTime		TINYINT		null,
		Monday				BIT			null,
		Tuesday				BIT			null,
		Wednesday			BIT			null,
		Thursday			BIT			null,
		Friday				BIT			null,
		Saturday			BIT			null,
		Sunday				BIT			null,
		DateOfMonth			TINYINT     null,		/* 1-31 */
		WeekOfMonth			TINYINT     null,		/* 1-4 */
		[DayOfWeek]			TINYINT	    null	/* 1-7 (Monday -> Sunday ) */

GO

/* 
	EveryDay
*/
UPDATE PatchAgentConfiguration
SET ScheduleType = 0, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 0
GO


/* Sunday */
UPDATE PatchAgentConfiguration
SET ScheduleType = 1, Sunday =1, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 1
GO


/* 
	Monday 
*/
UPDATE PatchAgentConfiguration
SET ScheduleType = 1, Monday =1, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 2
GO


/* 
	Tuesday 
*/
UPDATE PatchAgentConfiguration
SET ScheduleType = 1, Tuesday =1, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 3
GO


/* 
   Wednesday 
*/
UPDATE PatchAgentConfiguration
SET ScheduleType = 1, Wednesday =1, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 4
GO


/* 
	Thursday 
*/
UPDATE PatchAgentConfiguration
SET ScheduleType = 1, Thursday =1, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 5
GO


/* 
	Friday 
*/
UPDATE PatchAgentConfiguration
SET ScheduleType = 1, Friday =1, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 6
GO


/* 
	Saturday 
*/
UPDATE PatchAgentConfiguration
SET ScheduleType = 1, Saturday =1, ScheduleTime = ScheduledInstallTime_Hour
WHERE ScheduledInstallDay = 7
GO

