/*
_____________________________________________

	Update from DB Schema 6.0.0 to 6.0.1, add VirtualLevelGroup table

*/

use control

IF NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'[VirtualLevelGroup]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
	PRINT 'Creating VirtualLevelGroup table.'
	EXEC('CREATE TABLE control.dbo.VirtualLevelGroup (
		VirtualLevelGroup_ParentVirtualLevel int NOT NULL REFERENCES VirtualLevel(VirtualLevel_ID),
		VirtualLevelGroup_ChildVirtualLevel int NOT NULL REFERENCES VirtualLevel(VirtualLevel_ID),
		CONSTRAINT PK_VIRTUALLEVELGROUP PRIMARY KEY
		(
			VirtualLevelGroup_ParentVirtualLevel,
			VirtualLevelGroup_ChildVirtualLevel
		)
	)')

END
ELSE
	PRINT 'Not creating VirtualLevelGroup table, it already exists'
GO


if (@@error<>0)
	print 'bad.'
else
begin
PRINT 'Inserting version information.'
INSERT INTO Version(Version_SWVersion,Version_SVNumber, Version_Description) VALUES( 
	'6.0.1','SV0238-06B0', 'Update of NV Version 6.0.0 to Version 6.0.1 database schema.')
end
go

