/** UPGRD651.SQL **/
/** Upgrade script to add much-needed indexes to database tables. **/

IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'MachineID_idx'
		and o.name = "SMSEvent" and i.id = o.id)
 create index MachineID_idx on SMSEvent (MachineID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'Time_idx'
		and o.name = "SMSEvent" and i.id = o.id)
 create index Time_idx on SMSEvent (Time)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'EventID_idx'
		and o.name = "SMSEvent" and i.id = o.id)
 create index EventID_idx on SMSEvent (EventID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'EventType_idx'
		and o.name = "SMSEvent" and i.id = o.id)
 create index EventType_idx on SMSEvent (EventType)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'JobType_idx'
		and o.name = "Jobs" and i.id = o.id)
 create index JobType_idx on Jobs (JobType)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'JobID_idx'
		and o.name = "Jobs" and i.id = o.id)
 create index JobID_idx on Jobs (JobID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'LastUpdateTime_idx'
		and o.name = "Jobs" and i.id = o.id)
 create index LastUpdateTime_idx on Jobs (LastUpdateTime)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'JobStatus_idx'
		and o.name = "Jobs" and i.id = o.id)
 create index JobStatus_idx on Jobs (JobStatus)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'ActivateTime_idx'
		and o.name = "Jobs" and i.id = o.id)
 create index ActivateTime_idx on Jobs (ActivateTime)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'JobID_idx'
		and o.name = "Requests" and i.id = o.id)
 create index JobID_idx on Requests (JobID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'JobID_idx'
		and o.name = "JobDetails" and i.id = o.id)
 create index JobID_idx on JobDetails (JobID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'MachineID_idx'
		and o.name = "UserGroups" and i.id = o.id)
 create index MachineID_idx on UserGroups (MachineID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'MachineID_idx'
		and o.name = "PackageLocations" and i.id = o.id)
 create index MachineID_idx on PackageLocations (MachineID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'dwMachineID_idx'
		and o.name = "MachineDataHistoryTable" and i.id = o.id)
 create index dwMachineID_idx on MachineDataHistoryTable (dwMachineID)
go
IF NOT EXISTS (select * from sysindexes i, sysobjects o where i.name = 'TimeKey_idx'
		and o.name = "MachineDataHistoryTable" and i.id = o.id)
 create index TimeKey_idx on MachineDataHistoryTable (TimeKey)
go
