ALTER TABLE TBTRIBUTACAO_ICMS
    ADD GERA_DIFAL INTEGER DEFAULT 1 NOT NULL;

COMMENT ON COLUMN TBTRIBUTACAO_ICMS.GERA_DIFAL IS
'GERAR BLOCO DE ICMS UF DESTINO
0 - NAO;
1 - SIM;';

UPDATE TBTRIBUTACAO_ICMS T SET T.GERA_DIFAL = 0 WHERE T.CODIGO IN (40, 300, 400, 41, 103);

CREATE INDEX ITBTRIBUTACAO_ICMS_01
ON TBTRIBUTACAO_ICMS (GERA_DIFAL);

ALTER TABLE TBCFOP
    ADD GERA_DIFAL INTEGER DEFAULT 1 NOT NULL;

COMMENT ON COLUMN TBCFOP.GERA_DIFAL IS
'GERAR BLOCO DE ICMS UF DESTINO
0 - NAO;
1 - SIM;';

CREATE INDEX ITBCFOP_01
ON TBCFOP (GERA_DIFAL);

UPDATE TBCFOP T SET T.GERA_DIFAL = 0 WHERE T.TIPO = 'E';

UPDATE TBCFOP T SET T.GERA_DIFAL = 0 WHERE T.CODIGO IN ('6.552', '6.922', '6.929', '5.664', '5.665', '5.902', '5.903', '5.906', '5.907', '5.909', '5.913', '5.916', '5.925', '6.664', '6.665', '6.902', '6.903', '6.906', '6.907', '6.909', '6.913', '6.916', '6.925', '5.414', '5.415', '5.451', '5.501', '5.502', '5.504', '5.505', '5.554', '5.657', '5.663', '5.666', '5.901', '5.904', '5.905', '5.908', '5.910', '5.911', '5.911', '5.912', '5.914', '5.915', '5.917', '5.920', '5.923', '5.924', '5.934', '6.414', '6.415', '6.501', '6.502', '6.504', '6.505', '6.554', '6.657', '6.663', '6.666', '6.901', '6.904', '6.905', '6.908', '6.910', '6.911', '6.912', '6.914', '6.915', '6.917', '6.920', '6.923', '6.924', '6.934');
