USE [EnVisage]
GO

begin tran
	
	IF NOT EXISTS(SELECT * FROM sys.columns 
				WHERE Name = N'IsInclude' AND Object_ID = Object_ID(N'Holiday'))
	BEGIN
		ALTER TABLE Holiday ADD IsInclude bit NULL default 1
	END
	GO

	UPDATE Holiday SET IsInclude = 1 WHERE IsInclude IS NULL
	GO

	ALTER TABLE Holiday ALTER COLUMN IsInclude bit NOT NULL
	GO

	if exists (select 1 from sys.columns where name = 'HolidayId' and object_id = OBJECT_ID('Holiday'))
	begin
		exec sp_rename	@objname = 'Holiday.HolidayId',
						@newname = 'HolidayGroupId', 
						@objtype = 'COLUMN'
	end

commit tran