
------------------------------------------------------------------------------
-- ADVANTAGE 2004.4.5
-- SCHEMA CHANGES SINCE ADVANTAGE 2004.4.4
-- 04/08/2009
------------------------------------------------------------------------------


--------------------------------------------
-- ALTER COLUMS
--------------------------------------------

------------------------------------------------------------------------------
-- ADD COLUMNS  - COLUMN DROP statements commented to prevent loss of permanent data
------------------------------------------------------------------------------


--1. Modify AW_User_Companies table as follows
    IF NOT EXISTS
        (
            SELECT * FROM SysObjects O
                INNER JOIN SysColumns C
                    ON O.ID = C.ID
            WHERE ObjectProperty(O.ID,'IsUserTable') = 1 AND
                  O.Name='AW_User_Companies' AND
                  C.Name='Sp_Sales_File_Count'
        ) 
        BEGIN
            ALTER TABLE AW_User_Companies ADD Sp_Sales_File_Count int NULL
            -------------------------------------------------------
            EXEC sp_bindefault N'[dbo].[df_Numeric_Zero]', N'[AW_User_Companies].[Sp_Sales_File_Count]'
            -------------------------------------------------------
        END

---------------------------------------------------

--2. Modify AW_User_Companies table as follows
    IF NOT EXISTS
        (
            SELECT * FROM SysObjects O
                INNER JOIN SysColumns C
                    ON O.ID = C.ID
            WHERE ObjectProperty(O.ID,'IsUserTable') = 1 AND
                  O.Name='AW_User_Companies' AND
                  C.Name='Sp_Sales_File_Date'
        ) 
        BEGIN
            ALTER TABLE AW_User_Companies ADD Sp_Sales_File_Date datetime NULL
        END

---------------------------------------------------

--3. Modify AC_Customers table as follows
    IF NOT EXISTS
        (
            SELECT * FROM SysObjects O
                INNER JOIN SysColumns C
                    ON O.ID=C.ID
            WHERE ObjectProperty(O.ID,'IsUserTable') = 1 AND
                  O.Name='AC_Customers' AND
                  C.Name='AW_YesNo_Override_Credit_Limit'
        ) 
        BEGIN
            ALTER TABLE AC_Customers ADD AW_YesNo_Override_Credit_Limit tinyint NULL
            -------------------------------------------------------
            EXEC sp_bindefault N'[dbo].[df_Numeric_Zero]', N'[AC_Customers].[AW_YesNo_Override_Credit_Limit]'
            -------------------------------------------------------
        END

---------------------------------------------------

--4. Modify AC_Customers table as follows
    IF NOT EXISTS
        (
            SELECT * FROM SysObjects O
                INNER JOIN SysColumns C
                    ON O.ID=C.ID
            WHERE ObjectProperty(O.ID,'IsUserTable') = 1 AND
                  O.Name='AC_Customers' AND
                  C.Name='AW_YesNo_Override_Overdue'
        ) 
        BEGIN
            -------------------------------------------------------
            ALTER TABLE AC_Customers ADD AW_YesNo_Override_Overdue tinyint NULL
            -------------------------------------------------------
            EXEC sp_bindefault N'[dbo].[df_Numeric_Zero]', N'[AC_Customers].[AW_YesNo_Override_Overdue]'
            -------------------------------------------------------
        END

---------------------------------------------------

--5. Modify Lup_AS_CBilling_Providers table as follows
    IF NOT EXISTS
        (
            SELECT * FROM SysObjects O
                INNER JOIN SysColumns C
                    ON O.ID=C.ID
            WHERE ObjectProperty(O.ID,'IsUserTable') = 1 AND
                  O.Name='Lup_AS_CBilling_Providers' AND
                  C.Name='Folder'
        ) 
        BEGIN
            -------------------------------------------------------
            ALTER TABLE Lup_AS_CBilling_Providers ADD Folder varchar(50) NULL
            -------------------------------------------------------
            EXEC sp_bindefault N'[dbo].[df_Nullstring]', N'[Lup_AS_CBilling_Providers].[Folder]'
            -------------------------------------------------------
        END

--------------------------------------------
--  END
--------------------------------------------