IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'contactSourceSurface'
      AND Object_ID = Object_ID(N'pal_Campaign'))
BEGIN
    ALTER TABLE pal_Campaign
	ADD contactSourceSurface INT NULL; 
END

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

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

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

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

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

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

IF EXISTS ( SELECT * 
            FROM   sys.views 
            WHERE  name='pal_vSMSCreditHistory' and type='v')
BEGIN
    DROP VIEW [dbo].[pal_vSMSCreditHistory]
END

