IF NOT EXISTS(
    SELECT * FROM sys.columns 
    WHERE Name      = N'filterField'
      AND Object_ID = Object_ID(N'pal_CalendarEventModule'))
BEGIN
    ALTER TABLE pal_CalendarEventModule
	ADD filterField VARCHAR(255) NULL; 
END

IF NOT EXISTS(
    SELECT * FROM sys.columns 
    WHERE Name      = N'filterValue'
      AND Object_ID = Object_ID(N'pal_CalendarEventModule'))
BEGIN
    ALTER TABLE pal_CalendarEventModule
	ADD filterValue VARCHAR(255) NULL; 
END

IF (NOT EXISTS 
	(SELECT * FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_NAME = 'pal_CalendarEventContact'))
BEGIN
	CREATE TABLE [dbo].[pal_CalendarEventContact] (
		[recId]                INT           IDENTITY (1, 1) NOT NULL,
		[calendarEventId]      INT           NULL,
		[contactSurfaceItemId] INT           NULL,
		[recipientName]        VARCHAR (150) NULL,
		[recipientNumber]      VARCHAR (150) NULL,
		[isIncluded]           BIT           NULL,
		CONSTRAINT [PK_pal_CalendarEventContact] PRIMARY KEY CLUSTERED ([recId] ASC)
	);
END

IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_GetSurfaceCalendarUsersBySearch]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_GetSurfaceCalendarUsersBySearch]
END

