-- Dirk Strauss - 21 July 2016
-- Changes for Company Setup

PRINT N'Altering [dbo].[pal_Customer]...';
GO

IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'bankName'
      AND Object_ID = Object_ID(N'pal_Customer'))
BEGIN
ALTER TABLE [dbo].[pal_Customer]
    ADD [bankName]  VARCHAR (100) NULL;
END
GO


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


IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'bankBranch'
      AND Object_ID = Object_ID(N'pal_Customer'))
BEGIN
ALTER TABLE [dbo].[pal_Customer]
    ADD [bankBranch]  VARCHAR (100) NULL;
END
GO


IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'bankBranchCode'
      AND Object_ID = Object_ID(N'pal_Customer'))
BEGIN
ALTER TABLE [dbo].[pal_Customer]
    ADD [bankBranchCode]  VARCHAR (10) NULL;
END
GO


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



PRINT N'Altering [dbo].[pal_Setup]...';
GO



IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'bankName'
      AND Object_ID = Object_ID(N'pal_Setup'))
BEGIN
ALTER TABLE [dbo].[pal_Setup]
    ADD [bankName]  VARCHAR (100) NULL;
END
GO


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


IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'bankBranch'
      AND Object_ID = Object_ID(N'pal_Setup'))
BEGIN
ALTER TABLE [dbo].[pal_Setup]
    ADD [bankBranch]  VARCHAR (100) NULL;
END
GO


IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'bankBranchCode'
      AND Object_ID = Object_ID(N'pal_Setup'))
BEGIN
ALTER TABLE [dbo].[pal_Setup]
    ADD [bankBranchCode]  VARCHAR (10) NULL;
END
GO


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


PRINT N'Update complete.';

GO

