
/*------ ATD 422863 ------*/
DECLARE v_count NUMBER:=0;

BEGIN

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'PEDIDO_ECOMMERCE' and UPPER(column_name) = 'CODIGOFRANQUIA';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE PEDIDO_ECOMMERCE ADD CODIGOFRANQUIA VARCHAR2(3)';

END IF;

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'PONTO_RETIRADA_ECOMMERCE' and UPPER(column_name) = 'IDFRANQUIA';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE PONTO_RETIRADA_ECOMMERCE ADD IDFRANQUIA INT';

END IF;

SELECT COUNT(1) INTO v_count FROM USER_INDEXES WHERE UPPER(INDEX_NAME) = 'FRANQUIA_ECOMMERCE_IDX2';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'CREATE UNIQUE INDEX FRANQUIA_ECOMMERCE_IDX2 ON FRANQUIA_ECOMMERCE(RPLATAFORMA,CODIGO)';

END IF;

END;