-- +goose Up
DECLARE
    v_count NUMBER;
BEGIN
    SELECT COUNT(*) INTO v_count
      FROM USER_SEQUENCES
     WHERE SEQUENCE_NAME = 'SEQ_FLASH_VENDAS';

    IF v_count = 0 THEN
        EXECUTE IMMEDIATE 'CREATE SEQUENCE SEQ_FLASH_VENDAS
            START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE';
    END IF;
END;

-- +goose Down
DECLARE
    v_count NUMBER;
BEGIN
    SELECT COUNT(*) INTO v_count
      FROM USER_TRIGGERS
     WHERE TRIGGER_NAME = 'TRG_FLASH_VENDAS_BI';

    IF v_count > 0 THEN
        EXECUTE IMMEDIATE 'DROP TRIGGER TRG_FLASH_VENDAS_BI';
    END IF;
END;
