--add isDeleted
IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'isDeleted'
      AND Object_ID = Object_ID(N'pal_SurfaceItem'))
BEGIN
    ALTER TABLE pal_SurfaceItem
	ADD isDeleted BIT NOT NULL DEFAULT 0; 

	ALTER TABLE pal_SurfaceItem ALTER COLUMN isDeleted BIT NULL;
END
IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'isDeleted'
      AND Object_ID = Object_ID(N'pal_SalesItem'))
BEGIN
    ALTER TABLE pal_SalesItem
	ADD isDeleted BIT NOT NULL DEFAULT 0; 

	ALTER TABLE pal_SalesItem ALTER COLUMN isDeleted BIT NULL;
END



--update surface procs
IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_GetChildSurfaceData]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_GetChildSurfaceData]
END
IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_GetSalesCcEmailAddresses]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_GetSalesCcEmailAddresses]
END
IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_GetSurfaceData]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_GetSurfaceData]
END
IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_GetSurfaceDataAll]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_GetSurfaceDataAll]
END