
------------------------------------------------------------------------------
-- ADVANTAGE 2004.3.8
-- SCHEMA CHANGES SINCE ADVANTAGE 2004.3.7
-- 13 OCT 2008
------------------------------------------------------------------------------


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


--1. 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='AO_Suppliers' AND
                  C.Name='Lup_AO_Supplier_Types_ID'
        ) 
        BEGIN
            ALTER TABLE AO_Suppliers ADD Lup_AO_Supplier_Types_ID smallint NULL

            EXEC sp_bindefault N'[dbo].[df_Numeric_One]', N'[AO_Suppliers].[Lup_AO_Supplier_Types_ID]'
        END


--2. Modify AP_Products 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='AO_Suppliers' AND
                  C.Name='Lup_AO_Supplier_Groups_ID'
        ) 
        BEGIN
            ALTER TABLE AO_Suppliers ADD Lup_AO_Supplier_Groups_ID smallint NULL

            EXEC sp_bindefault N'[dbo].[df_Numeric_One]', N'[AO_Suppliers].[Lup_AO_Supplier_Groups_ID]'
        END


--3. Modify AW_Users 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_Users' AND
                  C.Name='IsProcurementSupervisor'
        ) 
        BEGIN
            ALTER TABLE AW_Users ADD IsProcurementSupervisor tinyint NULL

            EXEC sp_bindefault N'[dbo].[df_Numeric_Zero]', N'[AW_Users].[IsProcurementSupervisor]'
        END


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