/*
=======================================================================================
'Alteração de tabela
'DT Revisão: 27/12/2023
'Revisado por: Willian José
'=======================================================================================
*/
--Verifica se colunas existem DT_VIG_INI
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'EST_TRIB_ALIQ_MVA' AND COLUMN_NAME = ('DT_VIG_INI'))
BEGIN
    -- Adicionar as colunas DT_VIG_INI, DT_VIG_FIM e STATUS à tabela EST_TRIB_ALIQ_MVA
    ALTER TABLE EST_TRIB_ALIQ_MVA
        ADD DT_VIG_INI DATETIME;
END

--Verifica se colunas existem DT_VIG_FIM
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'EST_TRIB_ALIQ_MVA' AND COLUMN_NAME = ('DT_VIG_FIM'))
BEGIN
    -- Adicionar as colunas DT_VIG_INI, DT_VIG_FIM e STATUS à tabela EST_TRIB_ALIQ_MVA
    ALTER TABLE EST_TRIB_ALIQ_MVA
        ADD DT_VIG_FIM DATETIME;
END

--Verifica se colunas existem STATUS
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'EST_TRIB_ALIQ_MVA' AND COLUMN_NAME = ('STATUS'))
BEGIN
    -- Adicionar as colunas DT_VIG_INI, DT_VIG_FIM e STATUS à tabela EST_TRIB_ALIQ_MVA
    ALTER TABLE EST_TRIB_ALIQ_MVA
        ADD STATUS VARCHAR(10);
END