PRINT N'Altering [dbo].[pal_Customer]...';
GO
IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'vatNum'
      AND Object_ID = Object_ID(N'pal_Customer'))
BEGIN
ALTER TABLE [dbo].[pal_Customer]
    ADD [vatNum]  VARCHAR (50) NULL;
END
GO
IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'vatRate'
      AND Object_ID = Object_ID(N'pal_Customer'))
BEGIN
ALTER TABLE [dbo].[pal_Customer]
    ADD [vatRate] INT          NULL;
END
GO

PRINT N'Altering [dbo].[pal_Setup]...';
GO
IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'vatNum'
      AND Object_ID = Object_ID(N'pal_Setup'))
BEGIN
ALTER TABLE [dbo].[pal_Setup]
    ADD [vatNum]  VARCHAR (50) NULL;
END
GO
IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'vatRate'
      AND Object_ID = Object_ID(N'pal_Setup'))
BEGIN
ALTER TABLE [dbo].[pal_Setup]
    ADD [vatRate] INT          NULL;
END
GO


PRINT N'Altering [dbo].[pal_SurfaceField]...';
GO
IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'isUnique'
      AND Object_ID = Object_ID(N'pal_SurfaceField'))
BEGIN
ALTER TABLE [dbo].[pal_SurfaceField]
    ADD [isUnique] BIT CONSTRAINT [DF_pal_SurfaceField_isUnique] DEFAULT ((0)) NULL;
END

GO


PRINT N'Creating [dbo].[pal_SurfaceAction]...';
GO
IF NOT EXISTS (SELECT * 
                 FROM INFORMATION_SCHEMA.TABLES 
                 WHERE TABLE_SCHEMA = 'dbo' 
                 AND  TABLE_NAME = 'pal_SurfaceAction')
BEGIN
CREATE TABLE [dbo].[pal_SurfaceAction] (
    [recId]      INT          IDENTITY (1, 1) NOT NULL,
    [actionType] INT          NULL,
    [action]     VARCHAR (50) NULL,
    [isActive]   BIT          NULL,
    CONSTRAINT [PK_pal_SurfaceAction] PRIMARY KEY CLUSTERED ([recId] ASC)
);

ALTER TABLE [dbo].[pal_SurfaceAction]
    ADD CONSTRAINT [DF_pal_SurfaceAction_isActive] DEFAULT ((0)) FOR [isActive];
END

GO
PRINT N'Creating [dbo].[pal_SurfaceActionType]...';
GO

IF NOT EXISTS (SELECT * 
                 FROM INFORMATION_SCHEMA.TABLES 
                 WHERE TABLE_SCHEMA = 'dbo' 
                 AND  TABLE_NAME = 'pal_SurfaceActionType')
BEGIN
CREATE TABLE [dbo].[pal_SurfaceActionType] (
    [recId]      INT          IDENTITY (1, 1) NOT NULL,
    [actionType] VARCHAR (50) NULL,
    [isActive]   BIT          NOT NULL,
    CONSTRAINT [PK_pal_SurfaceActionType] PRIMARY KEY CLUSTERED ([recId] ASC)
);
ALTER TABLE [dbo].[pal_SurfaceActionType]
    ADD CONSTRAINT [DF_pal_SurfaceActionType_isActive] DEFAULT ((0)) FOR [isActive];
END

GO

PRINT N'Altering [dbo].[sp_GetSurfaceData]...';


GO
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
GO
PRINT N'Altering [dbo].[sp_GetSurfaceDataAll]...';


GO
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
GO
PRINT N'Altering [dbo].[sp_GetSurfaceItemData]...';


GO
IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_GetSurfaceItemData]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_GetSurfaceItemData]
END
GO
PRINT N'Altering [dbo].[sp_GetSurfaceItemGridData]...';


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

PRINT N'Update complete.';

GO

