--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'LATIN1';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: contacte
--

-- CREATE PROCEDURAL LANGUAGE plpgsql;


ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO contacte;

SET search_path = public, pg_catalog;

--
-- Name: areacornubada(character varying, character varying, character); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION areacornubada(fone character varying, mun_origem character varying DEFAULT ''::character varying, uf_origem character DEFAULT ''::bpchar) RETURNS character varying
    LANGUAGE plpgsql
    AS $$	
        DECLARE prefix char(6);
        DECLARE sufixo char(4);
        DECLARE uf_numero char(2);
        DECLARE mun_numero character varying(50);
        DECLARE result integer;
        BEGIN
		if(length(fone) < 10)then return fone; end if;
                if(mun_origem = '')then mun_numero = (select min(prm_mun_padrao) from pbx_parametros); else mun_numero = mun_origem; end if;
                if(uf_origem = '')then uf_numero = coalesce((select min(prm_uf_padrao) from pbx_parametros), 'MT'); else uf_numero = uf_origem; end if;
                prefix = substring(fone, 1, 6);
                sufixo = substring(fone, 7, 4);

                        result = (
                select count(*)
                  from pbx_municipios
                 where sigla_area_local = coalesce( (select min(sigla_area_local) from pbx_municipios where to_ascii( nome_municipio, 'LATIN1') =  to_ascii(upper(mun_numero), 'LATIN1') and uf = upper(uf_numero))::text, '')
                   and uf = uf_numero
                   and "prefixo" = prefix::int
                   and faixa_inicial <= sufixo::int
                   and faixa_final >= sufixo::int)::int;

                   if(result > 0)then return substring(fone,3,8); else return fone; end if;
        END;
        $$;


ALTER FUNCTION public.areacornubada(fone character varying, mun_origem character varying, uf_origem character) OWNER TO contacte;

--
-- Name: dias_nummes(integer, integer); Type: FUNCTION; Schema: public; Owner: root
--

CREATE FUNCTION dias_nummes(integer, integer) RETURNS integer
    LANGUAGE sql
    AS $_$
select
  extract(day from (date (trim(to_char($2, '0000'))||'-'||trim(to_char($1,
'00'))||'-01') + interval '1 month') - interval '1 day')::integer;
$_$;


ALTER FUNCTION public.dias_nummes(integer, integer) OWNER TO contacte;

--
-- Name: fn_atualiza_data_bilhete(); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION fn_atualiza_data_bilhete() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
begin 
	new.data_bilhete = new.calldate::date;	
	return new;
end;
$$;


ALTER FUNCTION public.fn_atualiza_data_bilhete() OWNER TO contacte;

--
-- Name: fn_atualiza_time_status(); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION fn_atualiza_time_status() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
begin 
	if old.status <> new.status then
		update pbx_supervisor_agentes set status_time = now() where matricula = old.matricula;
	end if;
	
	return null;
end;
$$;


ALTER FUNCTION public.fn_atualiza_time_status() OWNER TO contacte;

--
-- Name: fn_atualiza_vds_clas_data(); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION fn_atualiza_vds_clas_data() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
begin 
	new.clas_data = new.clas_reg::date;	
	return new;
end;
$$;


ALTER FUNCTION public.fn_atualiza_vds_clas_data() OWNER TO contacte;

--
-- Name: fn_atuliza_saldo_franquia(); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION fn_atuliza_saldo_franquia() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
declare 
dia_fechamento int;
dia_atu int;
ult_dia int;
tb_franquia_row pbx_tarif_franquia%ROWTYPE;
saldo int;
saldoMovel int;
begin 
	
	if((new.tfm_tipo_franquia <> 0) and (new.tfm_motivo <> 'INCLUSAO_SALDO'))then

		--select * into tb_franquia_row from pbx_tarif_franquia where contr_id = new.contr_id and tff_mes = new.tfm_mes;
                --saldo = tb_franquia_row.tff_saldo;
                --saldoMovel = tb_franquia_row.tff_saldo_movel;
		--insert into log_tarifa(log_text)values();
                --saldo = (select tff_saldo from pbx_tarif_franquia where contr_id = new.contr_id and tff_mes = new.tfm_mes);
                --saldoMovel = (select tff_saldo_movel from pbx_tarif_franquia where contr_id = new.contr_id and tff_mes = new.tfm_mes);

                
                --insert into log_tarifa(log_text)values('Saldo: ' || coalesce(saldo,0)::text);
                
		ult_dia = (select ultimo_dia_mes(new.tfm_data::date));			  
		dia_atu = (select date_part('day', new.tfm_data::date)::int);

		if(dia_atu > ult_dia)then dia_atu = ult_dia; end if;
		dia_fechamento = (select coalesce(contr_dia_fechamento, 15)  from pbx_tarif_contrato a  where a.contr_id = new.contr_id);

		if(dia_atu <= dia_fechamento)then new.tfm_mes = new.tfm_mes -1; end if;	
		
		if(not exists(select '' from pbx_tarif_franquia where contr_id = new.contr_id and tff_mes = new.tfm_mes))then
		
			insert 
			  into pbx_tarif_franquia( contr_id,       tff_mes,     tff_data,     tff_franquia,   tff_saldo,       tff_franquia_movel, tff_saldo_movel)
			select new.contr_id, new.tfm_mes, now(),   max(a.prc_franquia) * (case when(max(a.prc_tipo)::int = 1)then 60 else 1 end ),   max(a.prc_franquia) * (case when(max(a.prc_tipo)::int = 1)then 60 else 1 end ), max(a.prc_franquia_movel) * (case when(max(a.prc_tipo)::int = 1)then 60 else 1 end ),  max(a.prc_franquia_movel) * (case when(max(a.prc_tipo)::int = 1)then 60 else 1 end ) 
			  from pbx_tarif_contrato_preco a
			 where a.contr_id = new.contr_id;
				
		end if;

		select * into tb_franquia_row from pbx_tarif_franquia where contr_id = new.contr_id and tff_mes = new.tfm_mes;
                saldo = tb_franquia_row.tff_saldo;
                saldoMovel = tb_franquia_row.tff_saldo_movel;	
		
		if(new.tfm_tipo_franquia in (1,2))then
			update pbx_tarif_franquia set tff_saldo = tff_saldo + (new.tfm_lanc) where contr_id = new.contr_id and tff_mes = new.tfm_mes;
		end if;

		if(new.tfm_tipo_franquia = 3)then
		
			update pbx_tarif_franquia set tff_saldo_movel = tff_saldo_movel + (new.tfm_lanc) where contr_id = new.contr_id and tff_mes = new.tfm_mes;
			
		end if;

		if((new.tfm_tipo_franquia = 4) and (new.tmf_tipo_saldo = 'M'))then
		
			update pbx_tarif_franquia set tff_saldo_movel = tff_saldo_movel + (new.tfm_lanc) where contr_id = new.contr_id and tff_mes = new.tfm_mes;
			
		end if;

		if((new.tfm_tipo_franquia = 4) and (new.tmf_tipo_saldo = 'F'))then
		
			update pbx_tarif_franquia set tff_saldo = tff_saldo + (new.tfm_lanc) where contr_id = new.contr_id and tff_mes = new.tfm_mes;
		end if;
		
			
		--insert into log_tarifa(log_text)values('tfm_tipo_franquia: ' || coalesce( new.tfm_tipo_franquia,0)::text || ' tfm_lanc: ' || coalesce(new.tfm_lanc,0)::text ||  ' Saldo: ' || coalesce(saldo,0)::text);

		if((new.tfm_tipo_franquia in(1,2)) and (saldo > 0))then

		    if(saldo >= abs(new.tfm_lanc))then saldo = new.tfm_lanc; else saldo = (abs(new.tfm_lanc) - (saldo)); end if;
		    
		    update pbx_tarif_registra set trr_franquia = abs(saldo) where uniqueid = new.uniqueid;	

		elsif((new.tfm_tipo_franquia = 3) and (saldoMovel > 0))then

		    if(saldoMovel >= abs(new.tfm_lanc))then saldoMovel = new.tfm_lanc; else saldoMovel = (abs(new.tfm_lanc)- (saldoMovel)); end if;
		    update pbx_tarif_registra set trr_franquia = abs(saldoMovel) where uniqueid = new.uniqueid;	

		elsif((new.tfm_tipo_franquia = 4) and (new.tmf_tipo_saldo = 'F') and (saldo > 0))then

		   if(saldo >= abs(new.tfm_lanc))then saldo = new.tfm_lanc; else saldo = (abs(new.tfm_lanc) - (saldo)); end if;
		    update pbx_tarif_registra set trr_franquia = abs(saldo) where uniqueid = new.uniqueid;

		elsif((new.tfm_tipo_franquia = 4) and (new.tmf_tipo_saldo = 'M') and (saldoMovel > 0))then

                   if(saldoMovel >= abs(new.tfm_lanc))then saldoMovel = new.tfm_lanc; else saldoMovel = (abs(new.tfm_lanc) - (saldoMovel)); end if;
		   update pbx_tarif_registra set trr_franquia = abs(saldoMovel) where uniqueid = new.uniqueid;	
  
		end if;
		
	end if;

	
		
	return new;
end;
$$;


ALTER FUNCTION public.fn_atuliza_saldo_franquia() OWNER TO contacte;

--
-- Name: fn_atuliza_saldo_prepago(); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION fn_atuliza_saldo_prepago() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
declare
sql text;
saldo numeric(12,2);
tb_prepago_row pbx_prepago%ROWTYPE;
begin 

        --select * from pbx_prepago_movimento
	--Calcula o saldo atual
	saldo = (select sum(prm_valor) from pbx_prepago_movimento where prm_conta_senha = [REDACTED]  and prm_ramal_conta = new.prm_ramal_conta);

        --peag informacoes do ramal ou conta para atualizar o saldo
        select * into tb_prepago_row from pbx_prepago where tipo = new.prm_conta_senha  and id = new.prm_ramal_conta::text;

        

	sql = 'update ' || tb_prepago_row.tabela || ' set saldo_prepago = ' || saldo::text || ' where ' || tb_prepago_row.coluna::text || ' = ''' ||  new.prm_ramal_conta::text || '''';
        execute sql;
	
	return new;
end;
$$;


ALTER FUNCTION public.fn_atuliza_saldo_prepago() OWNER TO contacte;

--
-- Name: fn_franquia_alteracao(); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION fn_franquia_alteracao() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
declare 
tipo_franquia int;
saldo int;
tp_lanc char(1);
begin 

	--select * from pbx_tarif_franquia
        --select * from pbx_tarif_franquia_movimento

        tipo_franquia = (select contr_tipo_franquia from pbx_tarif_contrato where contr_id = new.contr_id); 
        
        if(new.tff_franquia <> old.tff_franquia)then
        
         saldo =  new.tff_franquia - old.tff_franquia;         
         if(saldo > 0)then tp_lanc = 'C'; else tp_lanc = 'D'; end if;
         new.tff_saldo = old.tff_saldo + (saldo);
         
		insert 
		  into pbx_tarif_franquia_movimento
		      ( prc_id, contr_id,      tfm_mes,     uniqueid, tfm_data, tfm_lanc,	  tfm_tipo_lanc,      tfm_motivo,       tfm_user,               tfm_tipo_franquia, tmf_tipo_saldo)
		values( 0,      new.contr_id,  new.tff_mes, 0,        now(),    saldo,            tp_lanc,            'INCLUSAO_SALDO', 'fn_franquia_inclusao', tipo_franquia,     'F');
			
	end if;	

	if(new.tff_franquia_movel <> old.tff_franquia_movel)then
	
		saldo =  new.tff_franquia_movel - old.tff_franquia_movel;
		if(saldo > 0)then tp_lanc = 'C'; else tp_lanc = 'D'; end if;
		new.tff_saldo_movel = old.tff_saldo_movel + (saldo);
		insert 
		  into pbx_tarif_franquia_movimento
		      ( prc_id, contr_id,      tfm_mes,     uniqueid, tfm_data, tfm_lanc,	         tfm_tipo_lanc,     tfm_motivo,       tfm_user,               tfm_tipo_franquia, tmf_tipo_saldo)
		values( 0,      new.contr_id,  new.tff_mes, 0,        now(),    saldo,                   tp_lanc,           'INCLUSAO_SALDO', 'fn_franquia_inclusao', tipo_franquia,     'M');
		
	end if;	
	
	return new;
end;
$$;


ALTER FUNCTION public.fn_franquia_alteracao() OWNER TO contacte;

--
-- Name: fn_franquia_inclusao(); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION fn_franquia_inclusao() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
declare 
tipo_franquia int;
t_contrato_row pbx_tarif_contrato%ROWTYPE;
begin 

	--select  * from pbx_tarif_franquia
        --select * from pbx_tarif_franquia_movimento



         select * into t_contrato_row from pbx_tarif_contrato where contr_id = new.contr_id;
         tipo_franquia = t_contrato_row.contr_tipo_franquia;
         new.contr_dia_fechamento = t_contrato_row.contr_dia_fechamento;
        
        
        if(new.tff_franquia <> 0)then
		insert 
		  into pbx_tarif_franquia_movimento
		      ( prc_id, contr_id,      tfm_mes,     uniqueid, tfm_data, tfm_lanc,	  tfm_tipo_lanc,      tfm_motivo,       tfm_user,               tfm_tipo_franquia, tmf_tipo_saldo)
		values( 0,      new.contr_id,  new.tff_mes, 0,        now(),    new.tff_franquia,  'C',               'INCLUSAO_SALDO', 'fn_franquia_inclusao', tipo_franquia,     'F');
		
	end if;	

	if(new.tff_franquia_movel <> 0)then
		insert 
		  into pbx_tarif_franquia_movimento
		      ( prc_id, contr_id,      tfm_mes,     uniqueid, tfm_data, tfm_lanc,	         tfm_tipo_lanc,     tfm_motivo,       tfm_user,               tfm_tipo_franquia, tmf_tipo_saldo)
		values( 0,      new.contr_id,  new.tff_mes, 0,        now(),    new.tff_franquia_movel,  'C',               'INCLUSAO_SALDO', 'fn_franquia_inclusao', tipo_franquia,     'M');
		
	end if;	
	
	return new;
end;
$$;


ALTER FUNCTION public.fn_franquia_inclusao() OWNER TO contacte;

--
-- Name: formata_segundos(double precision); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION formata_segundos(double precision) RETURNS character varying
    LANGUAGE sql
    AS $_$ select ($1 * interval '1 second'::time)::varchar $_$;


ALTER FUNCTION public.formata_segundos(double precision) OWNER TO contacte;

--
-- Name: get_descricao_chamada(integer); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION get_descricao_chamada(cod integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
BEGIN	
  
 if(cod = 1)then return 'Interna';
 elseif(cod =  4)then return 'Emergência';
 elseif(cod = 5)then return 'Gratuita';    
 elseif(cod = 21)then return 'Local Fixo';
 elseif(cod = 22)then return 'Interurbano Fixo';
 elseif(cod = 23)then return 'Local Móvel';
 elseif(cod = 24)then return 'Interurbano Móvel';
 elseif(cod = 25)then return 'Internacional';
 elseif(cod = 31)then return 'Local Fixo';
 elseif(cod = 32)then return 'Interurbano Fixo';
 elseif(cod = 33)then return 'Local Móvel';
 elseif(cod = 34)then return 'Interurbano Móvel';
 elseif(cod = 35)then return 'Internacional';
 else return 'NI'; end if;	
END; 
$$;


ALTER FUNCTION public.get_descricao_chamada(cod integer) OWNER TO contacte;

--
-- Name: get_prefixo_fone(character varying, character varying); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION get_prefixo_fone(ddd character varying, num_fone character varying) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
declare
tam integer;
str character varying(6);
fone character varying(10);
BEGIN	
	tam := length(num_fone);
	if(tam > 10)then 
		fone := substring(num_fone, '..........$'); 
		tam := 10;  
	else 
		fone := num_fone;
	end if;

	if(tam = 10)then 
		str := substring(fone,1,6); 
	elsif(tam = 9)then
		str := ddd || substring(fone,2,4); 
	elsif(tam = 8)then
		str := ddd || substring(fone,1, 4); 
	else
		str := '0';
	end if;
  
   return strtoint(str);
  
END;
$_$;


ALTER FUNCTION public.get_prefixo_fone(ddd character varying, num_fone character varying) OWNER TO contacte;

--
-- Name: getddd(character varying, integer); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION getddd(numfone character varying, ddddef integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
declare tam integer;
declare nonoDigito integer;
BEGIN	
   tam = length(numfone);
   nonoDigito = 0;
   /* Usa nono digito para testar se a ligacao é de móvel */
   if(tam > 8)then nonoDigito = strtoint( substring(substring(numfone, '.........$'), 1, 1) ); end if;

   /* Números com oito e nove digitos são considerados locais e retorma o ddd padrão */
   if( (tam >= 8) and (tam <= 9))then   
	return ddddef; 
   elsif(tam >= 10)then 
        /* Procura para ligacoes com 9 digitos */
        if((tam >= 11) and (nonoDigito = 9))then
		return substring(substring(numfone, '...........$'), 1, 2);
        else
		return substring(substring(numfone,  '..........$'), 1, 2);
	end if;
  end if;
/* ligacoes interanas gratuitas ou outras retorna vazio */
  return '';

  --return ini::text || '-' || tam::text || '-' || prefixo::text || '-' || emergencia;	
END; 
$_$;


ALTER FUNCTION public.getddd(numfone character varying, ddddef integer) OWNER TO contacte;

--
-- Name: gettipoligacao(character varying, integer); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION gettipoligacao(numfone character varying, ddd integer DEFAULT 0) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
declare tam integer;
declare dddfone integer;
declare nonoDigito integer;
declare ddddef integer;
declare numerofone varchar(18);
BEGIN	
      
        if(length(numfone) > 18)then 
	   numerofone = substring(numfone, '..................$');
	else 
	   numerofone = numfone;
        end if;
        
	ddddef = ddd;
	if(ddddef = 0)then
		ddddef = (select prm_ddd_padrao from pbx_parametros);
	end if;

	tam = length(strtoint(numerofone)::text);
	nonoDigito = strtoint( substring(substring(numerofone, '.........$'), 1, 1) ); 

	if((tam = 3) and (numerofone in('100', '128', '190', '191', '192', '193', '194', '197', '198', '199')))then 
		return 'EmergÃªncia';
	elsif(substring(numerofone,1,4) in('0300','0500','0900','4000','4001','4002','4003','4004', '4005', '4006','4007','4008','4009','0800'))then 
		return 'Gratuita';
	elsif(tam = 8)then   
		return 'Local Fixo';
	elsif(tam < 8)then   
		return 'Interna';
	elsif((nonoDigito = 9) and (tam = 9))then /* Celular local */
		return 'Local MÃ³vel';
	end if;

	
	if(nonoDigito = 9)then 
		dddfone = substring(substring(numerofone, '...........$'), 1, 2);
	else
		dddfone = substring(substring(numerofone, '..........$'), 1, 2);
		 
	end if;
   
	if((nonoDigito = 9) and (dddfone <> ddddef))then
		return 'Interurbano MÃ³vel'; 
	elsif((nonoDigito = 9) and (dddfone = ddddef))then
		return 'Local MÃ³vel';
	elsif(dddfone <> ddddef)then
		return 'Interurbano Fixo'; 
	elsif(dddfone = ddddef)then
		return 'Local Fixo';      
	end if;      
 	
END; 
$_$;


ALTER FUNCTION public.gettipoligacao(numfone character varying, ddd integer) OWNER TO contacte;

--
-- Name: iscolumn(character varying, character varying); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION iscolumn(tablenome character varying, columnname character varying) RETURNS integer
    LANGUAGE plpgsql
    AS $$
begin
	return (SELECT count(*) FROM information_schema.columns WHERE table_schema='public' AND table_name= tableNome and column_name = columnName)::int;

end $$;


ALTER FUNCTION public.iscolumn(tablenome character varying, columnname character varying) OWNER TO contacte;

--
-- Name: isnumeric(character varying); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION isnumeric(txt character varying) RETURNS boolean
    LANGUAGE plpgsql
    AS $_$
BEGIN

	return (coalesce(txt, '') ~ '^[0-9.-]+$');
END;
$_$;


ALTER FUNCTION public.isnumeric(txt character varying) OWNER TO contacte;

--
-- Name: istable(character varying); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION istable(tablenome character varying) RETURNS integer
    LANGUAGE plpgsql
    AS $$
begin
	return (SELECT  count(*) FROM pg_tables where tablename=tableNome)::int;

end $$;


ALTER FUNCTION public.istable(tablenome character varying) OWNER TO contacte;

--
-- Name: istmptable(character varying); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION istmptable(nometable character varying) RETURNS integer
    LANGUAGE plpgsql
    AS $$
BEGIN

	return case when( 
				(
					select count(*)
					   FROM pg_catalog.pg_class c 
					  inner join pg_catalog.pg_roles r ON r.oid = c.relowner 
					   left join pg_catalog.pg_namespace n ON n.oid = c.relnamespace 
					  where c.relkind in ('r','') 
					    and n.nspname  like 'pg_temp%' 
					    and pg_catalog.pg_table_is_visible(c.oid) 
					    and c.relname =  nometable
                                 ) > 0
                         )THEN 1 else 0 end;
END;
$$;


ALTER FUNCTION public.istmptable(nometable character varying) OWNER TO contacte;

--
-- Name: remove_acentos(text); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION remove_acentos(p_texto text) RETURNS text
    LANGUAGE sql
    AS $_$  
 Select translate($1,  
 'áàâãäåaaaÁÂÃÄÅAAAÀéèêëeeeeeEEEÉEEÈìíîïìiiiÌÍÎÏÌIIIóôõöoooòÒÓÔÕÖOOOùúûüuuuuÙÚÛÜUUUUçÇñÑýÝ',  
 'aaaaaaaaaAAAAAAAAAeeeeeeeeeEEEEEEEiiiiiiiiIIIIIIIIooooooooOOOOOOOOuuuuuuuuUUUUUUUUcCnNyY'   
  );  
 $_$;


ALTER FUNCTION public.remove_acentos(p_texto text) OWNER TO contacte;

--
-- Name: retornaopcao(character varying); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION retornaopcao(str character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
BEGIN	
   /* 
	Tenta relacionar o campo direcao da tabela pbx_bilhetes_complento com
	o campo opcao da view pbx_opcao_acao.  
    */
   if(strpos(lower(str),'anuncios') > 0)then  
	return 'anuncios';
   elsif(strpos(lower(str),'callback') > 0)then   
	return 'callback';
   elsif(strpos(lower(str),'conferencia') > 0)then   
	return 'conferencia';
   elsif(strpos(lower(str),'disa') > 0)then   
	return 'disa';
   elsif(strpos(lower(str),'fila') > 0)then   
	return 'filas';
   elsif(strpos(lower(str),'horarios') > 0)then   
	return 'horarios';
   elsif(strpos(lower(str),'ramal') > 0)then   
	return 'ramal';
   elsif(strpos(lower(str),'ura') > 0)then   
	return 'ura';
  elsif(strpos(lower(str),'voice') > 0)then   
	return 'voice';
  elsif(strpos(lower(str),'entrada') > 0)then   
	return 'voice';
  else
	return str; 
  end if;
END; 
$$;


ALTER FUNCTION public.retornaopcao(str character varying) OWNER TO contacte;

--
-- Name: sonumero(character varying); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION sonumero(str character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
declare 
fone varchar(100);
tam integer;
count integer;
BEGIN	
   tam := length(str);
   count := 1;
   fone := '';
   WHILE (count <= tam) LOOP
	if(substring(str,count,1) in ('0','1','2','3','4','5','6','7','8','9'))then 
		fone := fone || substring(str,count,1); 
	end if;
        count := count + 1;
   END LOOP;

   return fone;
  
END; 
$$;


ALTER FUNCTION public.sonumero(str character varying) OWNER TO contacte;

--
-- Name: strtoint(character varying, integer); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION strtoint(txt character varying, def integer DEFAULT 0) RETURNS bigint
    LANGUAGE plpgsql
    AS $_$
BEGIN

	return case when((coalesce(txt, '') ~ E'^(\\-|\\+)?\\d+$')) then txt::bigint else def::bigint end;
END;
$_$;


ALTER FUNCTION public.strtoint(txt character varying, def integer) OWNER TO contacte;

--
-- Name: tipoligacao(character varying, boolean); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION tipoligacao(numfone character varying, entrada boolean DEFAULT true) RETURNS integer
    LANGUAGE plpgsql
    AS $_$
declare tam integer;
declare dddfone integer;
declare ddddef integer;
declare nonoDigito integer;
declare numerofone varchar(18);
BEGIN	
	if(length(numfone) > 18)then 
	   numerofone = substring(numfone, '..................$');
	else 
	   numerofone = numfone;
        end if;
        
	ddddef = (select prm_ddd_padrao from pbx_parametros);

	tam = length(strtoint(numerofone)::text);
	nonoDigito = strtoint( substring(substring(numerofone, '.........$'), 1, 1) ); 

	if((tam = 3) and (numerofone in('100', '128', '190', '191', '192', '193', '194', '197', '198', '199')))then 
		return 4;
	elsif((tam >= 8) and (substring(numerofone,1,4) in('0300','0500','0900','4000','4001','4002','4003','4004', '4005', '4006','4007','4008','4009','0800')))then 
		return 5;
	elsif(tam = 8)then   
		return  (case when(entrada)then 21 else 31 end);
	elsif(tam < 8)then   
		return 1;
	elsif((nonoDigito = 9) and (tam < 11))then /* Celular local */
		return  (case when(entrada)then 23 else 33 end);
	elseif((not entrada) and (substring(numerofone,1,2) = '00'))then
		return 35;
	end if;

	
	if(nonoDigito = 9)then 
		dddfone = substring(substring(numerofone, '...........$'), 1, 2);
	else
		dddfone = substring(substring(numerofone, '..........$'), 1, 2);
		 
	end if;

	if((nonoDigito = 9) and (dddfone <> ddddef))then
		return  (case when(entrada)then 24 else 34 end);
	elsif((nonoDigito = 9) and (dddfone = ddddef))then
		return  (case when(entrada)then 23 else 33 end);
	elsif(dddfone <> ddddef)then
		return  (case when(entrada)then 22 else 32 end);
	elsif(dddfone = ddddef)then
		return  (case when(entrada)then 21 else 31 end); 
	end if; 
	
	return 1;     
 	
END; 
$_$;


ALTER FUNCTION public.tipoligacao(numfone character varying, entrada boolean) OWNER TO contacte;

--
-- Name: ultimo_dia_mes(date); Type: FUNCTION; Schema: public; Owner: contacte
--

CREATE FUNCTION ultimo_dia_mes(data date) RETURNS integer
    LANGUAGE plpgsql
    AS $$
DECLARE final integer;
BEGIN
	
	final = (select date_part('day', date_trunc('month', data)+'1month'::interval-'1day'::interval))::int;
	return final;
END;	
$$;


ALTER FUNCTION public.ultimo_dia_mes(data date) OWNER TO contacte;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: ast_bilhetes; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE ast_bilhetes (
    id_bilhetes bigint NOT NULL,
    calldate timestamp with time zone DEFAULT now() NOT NULL,
    clid character varying(80) DEFAULT ''::text NOT NULL,
    src character varying(80) DEFAULT ''::text NOT NULL,
    dst character varying(80) DEFAULT ''::text NOT NULL,
    dcontext character varying(80) DEFAULT ''::text NOT NULL,
    channel character varying(80) DEFAULT ''::text NOT NULL,
    dstchannel character varying(80) DEFAULT ''::text NOT NULL,
    lastapp character varying(80) DEFAULT ''::text NOT NULL,
    lastdata character varying(80) DEFAULT ''::text NOT NULL,
    duration bigint DEFAULT (0)::bigint NOT NULL,
    billsec bigint DEFAULT (0)::bigint NOT NULL,
    disposition character varying(45) DEFAULT ''::text NOT NULL,
    amaflags bigint DEFAULT (0)::bigint NOT NULL,
    accountcode character varying(20) DEFAULT ''::text NOT NULL,
    uniqueid character varying(32) DEFAULT ''::text NOT NULL,
    userfield character varying(200) DEFAULT ''::text NOT NULL,
    data_bilhete date DEFAULT (now())::date NOT NULL,
    flag_fila character(1),
    tipo_chamada integer,
    id_municipio integer,
    direcao character varying(10),
    ramal_origem character varying(80),
    linkedid character varying(32) DEFAULT ''::text,
    peeraccount character varying(80) DEFAULT ''::text,
    sequence bigint DEFAULT (0)::bigint NOT NULL,
    fora_horario integer
);


ALTER TABLE public.ast_bilhetes OWNER TO postgres;

--
-- Name: ast_bilhetes_complemento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE ast_bilhetes_complemento (
    uniqueid2 character varying(32) DEFAULT ''::text NOT NULL,
    direcao character varying(40) NOT NULL,
    id bigint NOT NULL,
    conta character varying(4),
    fone character varying(20),
    destino character varying(80),
    data_registro timestamp without time zone DEFAULT now() NOT NULL,
    id_usuario integer,
    agente character varying(20),
    dac character varying(100)
);


ALTER TABLE public.ast_bilhetes_complemento OWNER TO contacte;

--
-- Name: ast_bilhetes_complemento_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE ast_bilhetes_complemento_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.ast_bilhetes_complemento_id_seq OWNER TO contacte;

--
-- Name: ast_bilhetes_complemento_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE ast_bilhetes_complemento_id_seq OWNED BY ast_bilhetes_complemento.id;


--
-- Name: ast_bilhetes_id_bilhetes_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE ast_bilhetes_id_bilhetes_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.ast_bilhetes_id_bilhetes_seq OWNER TO postgres;

--
-- Name: ast_bilhetes_id_bilhetes_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE ast_bilhetes_id_bilhetes_seq OWNED BY ast_bilhetes.id_bilhetes;


--
-- Name: ast_eventos_dacs; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE ast_eventos_dacs (
    id integer NOT NULL,
    uid1 character varying(50) NOT NULL,
    uid2 character varying(50),
    fila character varying(50),
    agente character varying(50),
    evento character varying(80),
    param1 character varying(50),
    param2 character varying(50),
    param3 character varying(50),
    param4 character varying(50)
);


ALTER TABLE public.ast_eventos_dacs OWNER TO contacte;

--
-- Name: ast_eventos_dacs_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE ast_eventos_dacs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.ast_eventos_dacs_id_seq OWNER TO contacte;

--
-- Name: ast_eventos_dacs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE ast_eventos_dacs_id_seq OWNED BY ast_eventos_dacs.id;


--
-- Name: atualiza_routing; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE atualiza_routing (
    id_rout integer NOT NULL,
    spid integer DEFAULT 0,
    oper_numero character varying(40),
    prestadora character varying(100),
    licensa character varying(10),
    numero integer
);


ALTER TABLE public.atualiza_routing OWNER TO contacte;

--
-- Name: atualiza_routing_id_rout_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE atualiza_routing_id_rout_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.atualiza_routing_id_rout_seq OWNER TO contacte;

--
-- Name: atualiza_routing_id_rout_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE atualiza_routing_id_rout_seq OWNED BY atualiza_routing.id_rout;


--
-- Name: bilhetes_dupl; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE bilhetes_dupl (
    uniqueid character varying(32),
    sequence bigint
);


ALTER TABLE public.bilhetes_dupl OWNER TO contacte;

--
-- Name: cdr; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE cdr (
    id bigint NOT NULL,
    accountcode character varying(32),
    src character varying(128),
    dst character varying(128),
    dcontext character varying(128),
    clid character varying(128),
    channel character varying(128),
    dstchannel character varying(128),
    lastapp character varying(128),
    lastdata character varying(256),
    calldate timestamp without time zone NOT NULL,
    answerdate timestamp without time zone,
    hangupdate timestamp without time zone,
    duration integer DEFAULT 0 NOT NULL,
    billsec integer DEFAULT 0 NOT NULL,
    disposition character varying(128),
    amaflags character varying(256),
    uniqueid character varying(32),
    userfield character varying(256)
);


ALTER TABLE public.cdr OWNER TO contacte;

--
-- Name: cdr_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE cdr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.cdr_id_seq OWNER TO contacte;

--
-- Name: cdr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE cdr_id_seq OWNED BY cdr.id;


--
-- Name: gen_log; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE gen_log
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.gen_log OWNER TO contacte;

--
-- Name: increment; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE increment
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.increment OWNER TO contacte;

--
-- Name: log_tarifa_log_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE log_tarifa_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.log_tarifa_log_id_seq OWNER TO contacte;

--
-- Name: log_tarifa; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE log_tarifa (
    log_id integer DEFAULT nextval('log_tarifa_log_id_seq'::regclass) NOT NULL,
    log_text text
);


ALTER TABLE public.log_tarifa OWNER TO contacte;

--
-- Name: mkt_dados_anatel_scm; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE mkt_dados_anatel_scm (
    scm_id integer NOT NULL,
    scm_cnpj character varying(14),
    scm_razao_social character varying(256) NOT NULL,
    scm_processo character varying(32),
    scm_data_outorga date,
    scm_endereco character varying(256),
    scm_cidade character varying(128),
    scm_uf character(2),
    scm_telefone character varying(32),
    scm_celular character varying(32),
    scm_email character varying(128),
    scm_responsavel character varying(128),
    scm_responsavel_telefone character varying(32),
    scm_responsavel_celular character varying(32),
    scm_status character varying(32),
    scm_obs character varying(512)
);


ALTER TABLE public.mkt_dados_anatel_scm OWNER TO contacte;

--
-- Name: mkt_dados_anatel_scm_scm_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE mkt_dados_anatel_scm_scm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.mkt_dados_anatel_scm_scm_id_seq OWNER TO contacte;

--
-- Name: mkt_dados_anatel_scm_scm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE mkt_dados_anatel_scm_scm_id_seq OWNED BY mkt_dados_anatel_scm.scm_id;


--
-- Name: mkt_prospect; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE mkt_prospect (
    mkt_id integer NOT NULL,
    mkt_segmento character varying(64) DEFAULT 'provedor'::character varying NOT NULL,
    mkt_cnpj character varying(14),
    mkt_razao_social character varying(256) NOT NULL,
    mkt_processo character varying(32),
    mkt_data_outorga date,
    mkt_endereco character varying(256),
    mkt_cidade character varying(128),
    mkt_uf character(2),
    mkt_telefone character varying(32),
    mkt_celular character varying(32),
    mkt_email character varying(128),
    mkt_responsavel character varying(128),
    mkt_responsavel_telefone character varying(32),
    mkt_responsavel_celular character varying(32),
    mkt_responsavel_email character varying(128),
    mkt_status character varying(32),
    mkt_obs character varying(512),
    mkt_data_contato date,
    mkt_user_contato character varying(32),
    mkt_tipo_contato character varying(32),
    mkt_ref_id character varying(64)
);


ALTER TABLE public.mkt_prospect OWNER TO contacte;

--
-- Name: mkt_prospect_mkt_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE mkt_prospect_mkt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.mkt_prospect_mkt_id_seq OWNER TO contacte;

--
-- Name: mkt_prospect_mkt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE mkt_prospect_mkt_id_seq OWNED BY mkt_prospect.mkt_id;


--
-- Name: mkt_regiao_estados; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE mkt_regiao_estados (
    reg_sigla character(2) NOT NULL,
    reg_uf character(2) NOT NULL,
    reg_descricao character varying(64)
);


ALTER TABLE public.mkt_regiao_estados OWNER TO contacte;

--
-- Name: musichold_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE musichold_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.musichold_id_seq OWNER TO contacte;

--
-- Name: operadoras; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE operadoras (
    oper_id integer,
    oper_nome character varying(100),
    oper_spid integer,
    oper_licensa character varying(10),
    oper_numero character varying(4),
    oper_numero_saida character varying(4),
    oper_dono character(1)
);


ALTER TABLE public.operadoras OWNER TO contacte;

--
-- Name: pbx_usuarios_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_usuarios_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_usuarios_id_seq OWNER TO postgres;

--
-- Name: pbx_usuarios; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_usuarios (
    id integer DEFAULT nextval('pbx_usuarios_id_seq'::regclass) NOT NULL,
    nome character varying(60) NOT NULL,
    apelido character varying(20) NOT NULL,
    matricula character varying(4),
    flag integer DEFAULT 1,
    admin boolean DEFAULT false,
    senha character varying(50) DEFAULT 1234,
    supervisor boolean DEFAULT false,
    agente boolean DEFAULT true,
    email character varying(50),
    status boolean DEFAULT true,
    delete_ integer DEFAULT 0 NOT NULL,
    def_senha integer DEFAULT 1 NOT NULL,
    senha_expira integer DEFAULT 1 NOT NULL,
    senha_dias_expira integer DEFAULT 15,
    senha_ult_atualiza date DEFAULT ('now'::text)::date NOT NULL,
    penalidade integer DEFAULT 0 NOT NULL,
    dac_padrao integer,
    check_vl character varying(50) DEFAULT '0'::character varying NOT NULL,
    integra_vendas integer DEFAULT 0 NOT NULL,
    termo_uso_privacidade integer DEFAULT 0 NOT NULL,
    termo_uso_privacidade_log character varying(1024)
);


ALTER TABLE public.pbx_usuarios OWNER TO postgres;

--
-- Name: pabx_agentes; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_agentes AS
    SELECT pbx_usuarios.id AS agt_id, pbx_usuarios.nome AS agt_nome, pbx_usuarios.apelido AS agt_login, pbx_usuarios.matricula AS agt_matricula, pbx_usuarios.email AS agt_email, pbx_usuarios.penalidade AS agt_penalidade, pbx_usuarios.dac_padrao AS fila_id FROM pbx_usuarios WHERE (pbx_usuarios.delete_ = 0);


ALTER TABLE public.pabx_agentes OWNER TO contacte;

--
-- Name: pbx_eventos_agentes_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_eventos_agentes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_agentes_id_seq OWNER TO contacte;

--
-- Name: pbx_eventos_agentes_relaciona_eventos_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_eventos_agentes_relaciona_eventos_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_agentes_relaciona_eventos_seq OWNER TO contacte;

--
-- Name: pbx_eventos_agentes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_eventos_agentes (
    id integer DEFAULT nextval('pbx_eventos_agentes_id_seq'::regclass) NOT NULL,
    matricula character varying NOT NULL,
    ramal character varying NOT NULL,
    entrada_pausa timestamp(0) without time zone,
    saida_pausa timestamp(0) without time zone,
    id_motivo_pausa integer,
    login timestamp(0) without time zone,
    logoff timestamp(0) without time zone,
    duracao time(0) without time zone,
    id_dac integer NOT NULL,
    relaciona_eventos integer DEFAULT nextval('pbx_eventos_agentes_relaciona_eventos_seq'::regclass) NOT NULL,
    flag integer DEFAULT 10,
    pausa_produtiva integer DEFAULT 0 NOT NULL,
    pausa_produtiva_obs character varying(255),
    reg_proc character varying(1024),
    data_operacao date DEFAULT (now())::date NOT NULL
);


ALTER TABLE public.pbx_eventos_agentes OWNER TO contacte;

--
-- Name: pabx_agentes_eventos; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_agentes_eventos AS
    SELECT a.id AS agtevt_id, a.id_dac AS fila_id, a.matricula AS agt_matricula, a.ramal AS ramal_numero, a.entrada_pausa AS agtevt_entrada_pausa, a.saida_pausa AS agtevt_saida_pausa, a.id_motivo_pausa AS pausa_id, a.login AS agtevt_hora_login, a.logoff AS agtevt_hora_logoff FROM pbx_eventos_agentes a;


ALTER TABLE public.pabx_agentes_eventos OWNER TO contacte;

--
-- Name: pbx_bilhetes; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_bilhetes (
    id_bilhetes integer DEFAULT nextval(('"public"."pbx_bilhetes_id_bilhetes_seq"'::text)::regclass) NOT NULL,
    calldate timestamp with time zone DEFAULT now() NOT NULL,
    clid character varying(80) DEFAULT ''::text NOT NULL,
    src character varying(80) DEFAULT ''::text NOT NULL,
    dst character varying(80) DEFAULT ''::text NOT NULL,
    dcontext character varying(80) DEFAULT ''::text NOT NULL,
    channel character varying(80) DEFAULT ''::text NOT NULL,
    dstchannel character varying(80) DEFAULT ''::text NOT NULL,
    lastapp character varying(80) DEFAULT ''::text NOT NULL,
    lastdata character varying(80) DEFAULT ''::text NOT NULL,
    duration bigint DEFAULT (0)::bigint NOT NULL,
    billsec bigint DEFAULT (0)::bigint NOT NULL,
    disposition character varying(45) DEFAULT ''::text NOT NULL,
    amaflags bigint DEFAULT (0)::bigint NOT NULL,
    accountcode character varying(20) DEFAULT ''::text NOT NULL,
    uniqueid character varying(32) DEFAULT ''::text NOT NULL,
    userfield character varying(200) DEFAULT ''::text NOT NULL,
    data_bilhete date DEFAULT (now())::date NOT NULL,
    integra_vendas integer DEFAULT 0 NOT NULL,
    flag_fila character(1),
    tipo_chamada integer,
    id_municipio integer,
    linkedid character varying(32) DEFAULT ''::text,
    peeraccount character varying(80) DEFAULT ''::text,
    sequence bigint DEFAULT (0)::bigint NOT NULL,
    fora_horario integer,
    ramal_origem character varying(80)
);


ALTER TABLE public.pbx_bilhetes OWNER TO postgres;

--
-- Name: pabx_bilhetes; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_bilhetes AS
    SELECT a.id_bilhetes AS blt_id, a.calldate AS blt_data_hora, a.src AS blt_origem, a.dst AS blt_destino, a.billsec AS blt_tempo_conversacao, a.duration AS blt_tempo_atendimento, a.accountcode AS blt_id_transfer, a.uniqueid AS blt_id_chamada, a.userfield AS blt_nome_audio, a.data_bilhete AS blt_data FROM pbx_bilhetes a WHERE ((a.lastapp)::text <> 'Transferred Call'::text);


ALTER TABLE public.pabx_bilhetes OWNER TO contacte;

--
-- Name: pbx_bilhetes_complemento_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_bilhetes_complemento_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_bilhetes_complemento_id_seq OWNER TO contacte;

--
-- Name: pbx_bilhetes_complemento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_bilhetes_complemento (
    uniqueid2 character varying(32) DEFAULT ''::text NOT NULL,
    direcao character varying(40) NOT NULL,
    id integer DEFAULT nextval('pbx_bilhetes_complemento_id_seq'::regclass) NOT NULL,
    conta character varying(4),
    fone character varying(20),
    destino character varying(80),
    data_registro timestamp without time zone DEFAULT now() NOT NULL,
    id_usuario integer,
    agente character varying(20),
    dac character varying(100)
);


ALTER TABLE public.pbx_bilhetes_complemento OWNER TO contacte;

--
-- Name: pabx_bilhetes_complemento; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_bilhetes_complemento AS
    SELECT pbx_bilhetes_complemento.id AS blc_id, pbx_bilhetes_complemento.uniqueid2 AS blt_id_chamada, pbx_bilhetes_complemento.direcao AS blc_direcao, pbx_bilhetes_complemento.destino AS blc_destino, pbx_bilhetes_complemento.data_registro AS data_hora FROM pbx_bilhetes_complemento;


ALTER TABLE public.pabx_bilhetes_complemento OWNER TO contacte;

--
-- Name: pbx_classifica_atendimento_clas_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_classifica_atendimento_clas_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_classifica_atendimento_clas_id_seq OWNER TO postgres;

--
-- Name: pbx_classifica_atendimento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_classifica_atendimento (
    clas_id integer DEFAULT nextval('pbx_classifica_atendimento_clas_id_seq'::regclass) NOT NULL,
    clas_descricao character varying(100) NOT NULL,
    clas_status integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_classifica_atendimento OWNER TO contacte;

--
-- Name: pabx_classificacao; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_classificacao AS
    SELECT pbx_classifica_atendimento.clas_id, pbx_classifica_atendimento.clas_descricao FROM pbx_classifica_atendimento;


ALTER TABLE public.pabx_classificacao OWNER TO contacte;

--
-- Name: pbx_queues_grupos_id_seq1; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_queues_grupos_id_seq1
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_queues_grupos_id_seq1 OWNER TO contacte;

--
-- Name: pbx_queues_grupos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_queues_grupos (
    id integer DEFAULT nextval('pbx_queues_grupos_id_seq1'::regclass) NOT NULL,
    nome character varying(100),
    musicclass character varying(100),
    strategy character varying(100),
    servicelevel integer,
    timeout integer,
    retry integer,
    maxlen integer,
    joinempty character varying(3),
    eventwhencalled character varying(3),
    eventmemberstatus character varying(3),
    ringinuse character varying(3),
    periodic_announce_frequency integer,
    wrapuptime character varying(100),
    autofill character varying(100),
    autopause character varying(100),
    "announce-frequency" character varying(100),
    "announce-holdtime" character varying(100),
    "announce-round-seconds" character varying(100),
    "monitor-format" character varying(100),
    "monitor-type" character varying(100),
    reportholdtime character varying(100),
    timeoutrestart character varying(100),
    numero character varying(20),
    timeout2 character varying(10),
    m_espera character varying(1),
    opcao character varying(100),
    acao character varying(100),
    setinterfacevar character varying(3),
    status character(1) DEFAULT 'A'::bpchar,
    anuncio character varying(100),
    id_transbordo integer DEFAULT 0 NOT NULL,
    max_agente_pausa integer DEFAULT 0 NOT NULL,
    tempo_ring integer DEFAULT 45 NOT NULL,
    exige_classificacao integer DEFAULT 0 NOT NULL,
    justificativa_pausa integer DEFAULT 0 NOT NULL,
    context character varying(100),
    retornar_abandonadas integer DEFAULT 0 NOT NULL,
    data_reg_classificacao date,
    modo_atendimento character varying(20),
    id_pesquisa_liberacao integer,
    midiafila character varying(1) DEFAULT 'N'::character varying
);


ALTER TABLE public.pbx_queues_grupos OWNER TO contacte;

--
-- Name: pbx_dacs; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_dacs AS
    SELECT pbx_queues_grupos.id, pbx_queues_grupos.nome, pbx_queues_grupos.numero, pbx_queues_grupos.status FROM pbx_queues_grupos;


ALTER TABLE public.pbx_dacs OWNER TO contacte;

--
-- Name: pabx_filas; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_filas AS
    SELECT pbx_dacs.id AS fila_id, pbx_dacs.nome AS fila_nome FROM pbx_dacs WHERE (pbx_dacs.status = 'A'::bpchar);


ALTER TABLE public.pabx_filas OWNER TO contacte;

--
-- Name: pbx_classifica_item_clit_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_classifica_item_clit_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_classifica_item_clit_id_seq OWNER TO postgres;

--
-- Name: pbx_classifica_item; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_classifica_item (
    clit_id integer DEFAULT nextval('pbx_classifica_item_clit_id_seq'::regclass) NOT NULL,
    clas_id integer NOT NULL,
    clit_descricao character varying(100) NOT NULL,
    clit_status integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_classifica_item OWNER TO contacte;

--
-- Name: pabx_item_classificacao; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_item_classificacao AS
    SELECT pbx_classifica_item.clit_id, pbx_classifica_item.clas_id, pbx_classifica_item.clit_descricao FROM pbx_classifica_item;


ALTER TABLE public.pabx_item_classificacao OWNER TO contacte;

--
-- Name: pbx_motivos_pausas; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_motivos_pausas (
    id integer DEFAULT nextval(('"public"."pbx_motivos_pausas_id_seq"'::text)::regclass) NOT NULL,
    motivo character varying(50) NOT NULL,
    flag integer DEFAULT 1 NOT NULL,
    produtiva integer DEFAULT 0 NOT NULL,
    tempo_alerta integer
);


ALTER TABLE public.pbx_motivos_pausas OWNER TO postgres;

--
-- Name: pabx_pausas; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_pausas AS
    SELECT pbx_motivos_pausas.id AS pausa_id, pbx_motivos_pausas.motivo AS pausa_nome, pbx_motivos_pausas.produtiva AS pausa_produtiva FROM pbx_motivos_pausas;


ALTER TABLE public.pabx_pausas OWNER TO contacte;

--
-- Name: pbx_pesquisa; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa (
    pp_id integer NOT NULL,
    pp_nome character varying(80) NOT NULL,
    pp_data_inicio date,
    pp_data_fim date,
    pp_audio_saudacao character varying(255),
    pp_audio_encerramento character varying(255),
    pp_status integer DEFAULT 0 NOT NULL,
    pp_data date DEFAULT (now())::date NOT NULL,
    user_reg character varying(20),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_pesquisa OWNER TO contacte;

--
-- Name: pabx_pesquisa; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_pesquisa AS
    SELECT pbx_pesquisa.pp_id, pbx_pesquisa.pp_nome, pbx_pesquisa.pp_data_inicio, pbx_pesquisa.pp_data_fim, pbx_pesquisa.pp_audio_saudacao, pbx_pesquisa.pp_audio_encerramento, pbx_pesquisa.pp_status, pbx_pesquisa.pp_data FROM pbx_pesquisa;


ALTER TABLE public.pabx_pesquisa OWNER TO contacte;

--
-- Name: pbx_pesquisa_liberacao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_liberacao (
    pl_id integer NOT NULL,
    pp_id integer NOT NULL,
    pl_descricao character varying(80) NOT NULL,
    pl_data_inicio date,
    pl_data_fim date,
    pl_ativa integer DEFAULT 1 NOT NULL,
    user_reg character varying(20),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    pl_data date DEFAULT (now())::date NOT NULL
);


ALTER TABLE public.pbx_pesquisa_liberacao OWNER TO contacte;

--
-- Name: pabx_pesquisa_liberacao; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_pesquisa_liberacao AS
    SELECT pbx_pesquisa_liberacao.pl_id, pbx_pesquisa_liberacao.pp_id, pbx_pesquisa_liberacao.pl_descricao, pbx_pesquisa_liberacao.pl_data_inicio, pbx_pesquisa_liberacao.pl_data_fim, pbx_pesquisa_liberacao.pl_ativa, pbx_pesquisa_liberacao.pl_data FROM pbx_pesquisa_liberacao;


ALTER TABLE public.pabx_pesquisa_liberacao OWNER TO contacte;

--
-- Name: pbx_pesquisa_movimento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_movimento (
    pm_id integer NOT NULL,
    pl_id integer NOT NULL,
    pp_id integer NOT NULL,
    pq_id integer NOT NULL,
    po_id integer NOT NULL,
    uniqueid character varying(32) NOT NULL,
    pm_data date,
    user_reg character varying(20),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    id_dac integer,
    integra_vendas integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_pesquisa_movimento OWNER TO contacte;

--
-- Name: pabx_pesquisa_movimento; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_pesquisa_movimento AS
    SELECT pbx_pesquisa_movimento.pm_id, pbx_pesquisa_movimento.pl_id, pbx_pesquisa_movimento.pp_id, pbx_pesquisa_movimento.pq_id, pbx_pesquisa_movimento.po_id, pbx_pesquisa_movimento.uniqueid AS blt_id_chamada, pbx_pesquisa_movimento.pm_data, pbx_pesquisa_movimento.id_dac AS fila_id FROM pbx_pesquisa_movimento;


ALTER TABLE public.pabx_pesquisa_movimento OWNER TO contacte;

--
-- Name: pbx_pesquisa_opcoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_opcoes (
    pp_id integer NOT NULL,
    pq_id integer NOT NULL,
    po_id integer NOT NULL,
    po_display integer NOT NULL,
    po_opcao character varying(1024) NOT NULL,
    po_status integer DEFAULT 1 NOT NULL,
    user_reg character varying(20),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    po_tecla integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_pesquisa_opcoes OWNER TO contacte;

--
-- Name: pabx_pesquisa_opcoes; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_pesquisa_opcoes AS
    SELECT pbx_pesquisa_opcoes.pp_id, pbx_pesquisa_opcoes.pq_id, pbx_pesquisa_opcoes.po_id, pbx_pesquisa_opcoes.po_display, pbx_pesquisa_opcoes.po_opcao, pbx_pesquisa_opcoes.po_status FROM pbx_pesquisa_opcoes;


ALTER TABLE public.pabx_pesquisa_opcoes OWNER TO contacte;

--
-- Name: pbx_pesquisa_questoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_questoes (
    pp_id integer NOT NULL,
    pq_id integer NOT NULL,
    pq_display integer NOT NULL,
    pq_questao character varying(2048) NOT NULL,
    pq_audio character varying(255),
    pq_status integer DEFAULT 1 NOT NULL,
    user_reg character varying(20),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    pq_tipo integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_pesquisa_questoes OWNER TO contacte;

--
-- Name: pabx_pesquisa_questoes; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_pesquisa_questoes AS
    SELECT pbx_pesquisa_questoes.pp_id, pbx_pesquisa_questoes.pq_id, pbx_pesquisa_questoes.pq_display, pbx_pesquisa_questoes.pq_questao, pbx_pesquisa_questoes.pq_audio, pbx_pesquisa_questoes.pq_status FROM pbx_pesquisa_questoes;


ALTER TABLE public.pabx_pesquisa_questoes OWNER TO contacte;

--
-- Name: pbx_sip_ramais_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_sip_ramais_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_sip_ramais_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_sip_ramais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_sip_ramais (
    id integer DEFAULT nextval('pbx_sip_ramais_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    type character varying(8),
    secret character varying(100),
    qualify character varying(3),
    port integer,
    pickupgroup character varying(100),
    permit character varying(100),
    nat character(3),
    mailbox character varying(100),
    host character varying(100),
    dtmfmode character varying(100),
    context character varying(100),
    canreinvite character varying(3),
    callerid character varying(100),
    callgroup character varying(100),
    accountcode character varying(100),
    disallow character varying(100),
    allow character varying(254),
    "call-limit" character varying(100),
    deny character varying(100),
    videosupport character varying(3),
    fromuser character varying(100),
    fromdomain character varying(100),
    t38pt_udptl character varying(100),
    insecure character varying(100),
    espera character varying(1),
    sigame_interno character varying(20),
    sigame_externo character varying(20),
    sigame_naoatende character varying(20),
    sigame_ocupado character varying(20),
    gravacao_chamada character varying(1),
    nao_pertube character varying(1),
    cadeado character varying(1),
    senha_voice character varying(10),
    musica_espera character varying(100),
    dispositivo character varying(250),
    gravacao_saida character varying(1),
    senha_facilidade character varying(100),
    callerid2 character varying(100),
    conta_senha character varying(1) DEFAULT 'V'::character varying NOT NULL,
    ramalsecretaria character varying(20),
    saldo_prepago numeric(12,4) DEFAULT 0,
    habilita_prepago integer DEFAULT 0 NOT NULL,
    ring_time character varying(100),
    timeout character varying(16),
    extranet character varying(256),
    incluido_restricao integer DEFAULT 0 NOT NULL,
    midiaramal character varying(1) DEFAULT 'N'::character varying
);


ALTER TABLE public.pbx_sip_ramais OWNER TO contacte;

--
-- Name: pabx_ramais; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_ramais AS
    SELECT pbx_sip_ramais.nome AS ramal_numero, pbx_sip_ramais.port AS ramal_porta, pbx_sip_ramais.callerid AS ramal_bina FROM pbx_sip_ramais;


ALTER TABLE public.pabx_ramais OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_classifica_reg; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_classifica_reg (
    matricula character varying(4) NOT NULL,
    clas_id integer NOT NULL,
    clit_id integer NOT NULL,
    id_bilhetes character varying(32) NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    contrib_id integer,
    id_dac integer,
    mun_id integer,
    integra_vendas integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_classifica_reg OWNER TO postgres;

--
-- Name: pabx_registra_classificacao; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pabx_registra_classificacao AS
    SELECT a.matricula AS agt_matricula, a.clas_id, a.clit_id, a.id_bilhetes AS blt_id_chamada, a.data_reg AS rcl_data_hora, a.id_dac AS fila_id FROM pbx_classifica_reg a;


ALTER TABLE public.pabx_registra_classificacao OWNER TO contacte;

--
-- Name: pbx_abandonadas_semretorno; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_abandonadas_semretorno (
    abdsr_uniqueid character varying(32) NOT NULL,
    abdsr_fila character varying(64) NOT NULL,
    abdsr_data date DEFAULT (now())::date NOT NULL,
    abdsr_numero character varying(32) NOT NULL,
    abdsr_data_hora_inicio timestamp without time zone DEFAULT now() NOT NULL,
    abdsr_data_hora_retorno timestamp without time zone,
    abdsr_data_retorno date,
    abdsr_ramal character varying(32),
    abdsr_agente character varying(32),
    abdsr_agt_logado integer,
    abdsr_agt_pausa integer,
    abdsr_agt_ocupado integer,
    abdsr_agt_indisponivel integer,
    abdsr_agt_nao_classificado integer,
    abdsr_uniqueid_ret character varying(32),
    abdsr_log character varying(1024),
    abdsr_callback integer DEFAULT 0 NOT NULL,
    abdsr_callback_data timestamp without time zone
);


ALTER TABLE public.pbx_abandonadas_semretorno OWNER TO contacte;

--
-- Name: pbx_abandonadas_status; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_abandonadas_status (
    uniqueid character varying(32) NOT NULL,
    fila character varying(64) NOT NULL,
    matricula character varying(16) NOT NULL,
    id_evt_agt integer,
    status character varying(32),
    ramal character varying(32),
    disponivel integer,
    classificado integer,
    motivo_pausa character varying(64)
);


ALTER TABLE public.pbx_abandonadas_status OWNER TO contacte;

--
-- Name: pbx_administrador_funcoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_administrador_funcoes (
    fun_nome character varying(50) NOT NULL
);


ALTER TABLE public.pbx_administrador_funcoes OWNER TO contacte;

--
-- Name: pbx_agenda_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_agenda_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_agenda_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_agenda; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_agenda (
    id integer DEFAULT nextval('pbx_agenda_id_seq'::regclass) NOT NULL,
    telefone character varying(20),
    nome character varying(100),
    tipo character varying(20),
    ramal character varying(20),
    posicao integer
);


ALTER TABLE public.pbx_agenda OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_agenda_servidores; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_agenda_servidores (
    id_servidor integer NOT NULL,
    ip_servidores character varying(255),
    porta character varying(4)
);


ALTER TABLE public.pbx_agenda_servidores OWNER TO contacte;

--
-- Name: pbx_agenda_servidores_id_servidor_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_agenda_servidores_id_servidor_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_agenda_servidores_id_servidor_seq OWNER TO contacte;

--
-- Name: pbx_agenda_servidores_id_servidor_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_agenda_servidores_id_servidor_seq OWNED BY pbx_agenda_servidores.id_servidor;


--
-- Name: pbx_agendas_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_agendas_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_agendas_id_seq OWNER TO postgres;

--
-- Name: pbx_agendas; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_agendas (
    id integer DEFAULT nextval('pbx_agendas_id_seq'::regclass) NOT NULL,
    nome character varying(60) NOT NULL,
    telefone character(25) NOT NULL,
    celular character(20) NOT NULL,
    email character varying(50) NOT NULL,
    endereco character varying(80) NOT NULL
);


ALTER TABLE public.pbx_agendas OWNER TO postgres;

--
-- Name: pbx_agente_funcoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_agente_funcoes (
    fun_nome character varying(50) NOT NULL
);


ALTER TABLE public.pbx_agente_funcoes OWNER TO contacte;

--
-- Name: pbx_agents_agents; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_agents_agents (
    maxlogintries integer NOT NULL,
    autologoffunavail character varying(3),
    ackcall character varying(3),
    endcall character varying(3),
    wrapuptime integer,
    musiconhold character varying(100),
    goodbye character varying(100),
    updatecdr character varying(3) DEFAULT 'no'::character varying,
    "group" integer,
    recordagentcalls character varying(3) DEFAULT 'yes'::character varying,
    recordformat character varying(100),
    urlprefix character varying(100),
    savecallsin character varying(100),
    custom_beep character varying(100),
    autologoff character varying(3)
);


ALTER TABLE public.pbx_agents_agents OWNER TO contacte;

--
-- Name: pbx_agents_general; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_agents_general (
    persistentagents character varying(3) NOT NULL,
    multiplelogin character varying(3) NOT NULL
);


ALTER TABLE public.pbx_agents_general OWNER TO contacte;

--
-- Name: pbx_agents_usuarios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_agents_usuarios (
    id character varying(100) NOT NULL,
    login character varying(100) NOT NULL,
    senha character varying(100)
);


ALTER TABLE public.pbx_agents_usuarios OWNER TO contacte;

--
-- Name: pbx_anotacoes_id_text_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_anotacoes_id_text_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_anotacoes_id_text_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_anotacoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_anotacoes (
    id_text integer DEFAULT nextval('pbx_anotacoes_id_text_seq'::regclass) NOT NULL,
    conteudo text,
    matricula_agente integer,
    fone_cliente character varying(21),
    data timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_anotacoes OWNER TO contacte;

--
-- Name: pbx_anuncios_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_anuncios_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_anuncios_id_seq OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_anuncios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_anuncios (
    id integer DEFAULT nextval('pbx_anuncios_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    musica character varying(100),
    teste character varying(10),
    opcao character varying(100),
    acao character varying(100)
);


ALTER TABLE public.pbx_anuncios OWNER TO contacte;

--
-- Name: pbx_arquivo_som; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_arquivo_som (
    arq_id integer NOT NULL,
    arq_data date DEFAULT (now())::date NOT NULL,
    arq_nome character varying(255) NOT NULL,
    arq_nome_sistema character varying(255) NOT NULL,
    arq_descricao character varying(255),
    arq_path_origem character varying(1024),
    arq_path_destino character varying(1024),
    arq_orig_tamanho integer,
    arq_dest_tamanho integer,
    arq_md5 character varying(64),
    userreg character varying(32),
    datareg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_arquivo_som OWNER TO contacte;

--
-- Name: pbx_arquivo_som_arq_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_arquivo_som_arq_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_arquivo_som_arq_id_seq OWNER TO contacte;

--
-- Name: pbx_arquivo_som_arq_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_arquivo_som_arq_id_seq OWNED BY pbx_arquivo_som.arq_id;


--
-- Name: pbx_audita; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_audita (
    aud_id bigint NOT NULL,
    id_prog integer NOT NULL,
    aud_data date DEFAULT (now())::date NOT NULL,
    aud_ip character varying(32),
    aud_tabela character varying(50) NOT NULL,
    aud_campo character varying(50),
    aud_campo_display character varying(50),
    aud_operacao character(3),
    aud_valor_antigo text,
    aud_valor_novo text,
    reg_id bigint,
    aud_uid bigint,
    user_reg character varying(32),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_audita OWNER TO contacte;

--
-- Name: pbx_audita_aud_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_audita_aud_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_audita_aud_id_seq OWNER TO contacte;

--
-- Name: pbx_audita_aud_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_audita_aud_id_seq OWNED BY pbx_audita.aud_id;


--
-- Name: pbx_audita_full; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_audita_full (
    full_id bigint NOT NULL,
    full_data date DEFAULT (now())::date NOT NULL,
    login character varying(64),
    full_data_hora timestamp without time zone DEFAULT now() NOT NULL,
    id_prog integer,
    full_ip character varying(50),
    full_uid character varying(64),
    full_prog_nome character varying(64),
    full_tipo character varying(16),
    full_log text
);


ALTER TABLE public.pbx_audita_full OWNER TO contacte;

--
-- Name: pbx_audita_full_full_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_audita_full_full_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_audita_full_full_id_seq OWNER TO contacte;

--
-- Name: pbx_audita_full_full_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_audita_full_full_id_seq OWNED BY pbx_audita_full.full_id;


--
-- Name: pbx_aviso_franquia_reg; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_aviso_franquia_reg (
    contrato character varying(100) NOT NULL,
    data_aviso date DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_aviso_franquia_reg OWNER TO contacte;

--
-- Name: pbx_backup; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup (
    bkp_id integer NOT NULL,
    cfg_id integer,
    tp_id integer,
    bkp_arquivo character varying(1024),
    bkp_tamanho integer,
    bkp_data date,
    bkp_hora integer,
    bkp_minuto integer,
    bkp_status integer DEFAULT 0 NOT NULL,
    bkp_log text,
    bkp_log_erro text,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    user_reg character varying(30)
);


ALTER TABLE public.pbx_backup OWNER TO contacte;

--
-- Name: pbx_backup_arquivos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup_arquivos (
    arq_id integer NOT NULL,
    bkp_id integer,
    cfg_id integer NOT NULL,
    arq_nome character varying(1024),
    arq_destino character varying(1024),
    arq_size integer,
    uniqueid character varying(32),
    arq_data timestamp without time zone DEFAULT now() NOT NULL,
    arq_hash character varying(40) NOT NULL
);


ALTER TABLE public.pbx_backup_arquivos OWNER TO contacte;

--
-- Name: pbx_backup_arquivos_arq_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_backup_arquivos_arq_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_backup_arquivos_arq_id_seq OWNER TO contacte;

--
-- Name: pbx_backup_arquivos_arq_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_backup_arquivos_arq_id_seq OWNED BY pbx_backup_arquivos.arq_id;


--
-- Name: pbx_backup_bkp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_backup_bkp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_backup_bkp_id_seq OWNER TO contacte;

--
-- Name: pbx_backup_bkp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_backup_bkp_id_seq OWNED BY pbx_backup.bkp_id;


--
-- Name: pbx_backup_configuracao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup_configuracao (
    cfg_id integer NOT NULL,
    cfg_descricao character varying(80) NOT NULL,
    dst_id integer NOT NULL,
    cfg_destino_desc character varying(1024),
    tp_id integer NOT NULL,
    frq_id integer NOT NULL,
    qt_id integer,
    cfg_deleta_antigo integer,
    cfg_email character varying(1024),
    cfg_status integer DEFAULT 1 NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    user_reg character varying(30)
);


ALTER TABLE public.pbx_backup_configuracao OWNER TO contacte;

--
-- Name: pbx_backup_configuracao_cfg_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_backup_configuracao_cfg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_backup_configuracao_cfg_id_seq OWNER TO contacte;

--
-- Name: pbx_backup_configuracao_cfg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_backup_configuracao_cfg_id_seq OWNED BY pbx_backup_configuracao.cfg_id;


--
-- Name: pbx_backup_destino; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup_destino (
    dst_id integer NOT NULL,
    prt_id integer,
    dst_nome character varying(50),
    dst_host character varying(30),
    dst_porta integer,
    dst_user_anonimo integer DEFAULT 0 NOT NULL,
    dst_user character varying(30),
    dst_senha character varying(128),
    dst_diretorio_remoto character varying(255),
    dst_diretorio_local character varying(255),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    user_reg character varying(30),
    dst_clas_audio integer
);


ALTER TABLE public.pbx_backup_destino OWNER TO contacte;

--
-- Name: pbx_backup_destino_dst_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_backup_destino_dst_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_backup_destino_dst_id_seq OWNER TO contacte;

--
-- Name: pbx_backup_destino_dst_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_backup_destino_dst_id_seq OWNED BY pbx_backup_destino.dst_id;


--
-- Name: pbx_backup_frequencia; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup_frequencia (
    frq_id integer NOT NULL,
    frq_descricao character varying(80) NOT NULL
);


ALTER TABLE public.pbx_backup_frequencia OWNER TO contacte;

--
-- Name: pbx_backup_frequencia_qtde; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup_frequencia_qtde (
    qt_id integer NOT NULL,
    frq_id integer NOT NULL,
    qt_descricao character varying(80) NOT NULL,
    qt_agenda character varying(255)
);


ALTER TABLE public.pbx_backup_frequencia_qtde OWNER TO contacte;

--
-- Name: pbx_backup_protocolo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup_protocolo (
    prt_id integer NOT NULL,
    prt_descricao character varying(50) NOT NULL,
    prt_status integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_backup_protocolo OWNER TO contacte;

--
-- Name: pbx_backup_tipo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backup_tipo (
    tp_id integer NOT NULL,
    tp_desc character varying(50) NOT NULL
);


ALTER TABLE public.pbx_backup_tipo OWNER TO contacte;

--
-- Name: pbx_backups_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_backups_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_backups_id_seq OWNER TO contacte;

--
-- Name: pbx_backups; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_backups (
    id integer DEFAULT nextval('pbx_backups_id_seq'::regclass) NOT NULL,
    data date,
    hora time without time zone,
    tabela character(100),
    tipo character(1),
    comando_retorno text,
    padrao boolean,
    executa_reload character varying(100),
    teste character varying(50)
);


ALTER TABLE public.pbx_backups OWNER TO contacte;

--
-- Name: pbx_bilhetes_id_bilhetes_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_bilhetes_id_bilhetes_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_bilhetes_id_bilhetes_seq OWNER TO contacte;

--
-- Name: pbx_bilhetes_online; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_bilhetes_online (
    id_bilhetes integer,
    data date
);


ALTER TABLE public.pbx_bilhetes_online OWNER TO contacte;

--
-- Name: pbx_bilhetes_wpp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_bilhetes_wpp (
    id_bilhetes integer NOT NULL,
    calldate timestamp with time zone DEFAULT now() NOT NULL,
    clid character varying(80) DEFAULT ''::text NOT NULL,
    src character varying(80) DEFAULT ''::text NOT NULL,
    dst character varying(80) DEFAULT ''::text NOT NULL,
    dcontext character varying(80) DEFAULT ''::text NOT NULL,
    channel character varying(80) DEFAULT ''::text NOT NULL,
    dstchannel character varying(80) DEFAULT ''::text NOT NULL,
    lastapp character varying(80) DEFAULT ''::text NOT NULL,
    lastdata character varying(80) DEFAULT ''::text NOT NULL,
    duration bigint DEFAULT (0)::bigint NOT NULL,
    billsec bigint DEFAULT (0)::bigint NOT NULL,
    disposition character varying(45) DEFAULT ''::text NOT NULL,
    amaflags bigint DEFAULT (0)::bigint NOT NULL,
    accountcode character varying(20) DEFAULT ''::text NOT NULL,
    uniqueid character varying(32) DEFAULT ''::text NOT NULL,
    userfield character varying(200) DEFAULT ''::text NOT NULL,
    data_bilhete date DEFAULT (now())::date NOT NULL,
    integra_vendas integer DEFAULT 0 NOT NULL,
    flag_fila character(1),
    tipo_chamada integer,
    id_municipio integer,
    linkedid character varying(32) DEFAULT ''::text,
    peeraccount character varying(80) DEFAULT ''::text,
    sequence bigint DEFAULT (0)::bigint NOT NULL,
    fora_horario integer,
    ramal_origem character varying(80)
);


ALTER TABLE public.pbx_bilhetes_wpp OWNER TO contacte;

--
-- Name: pbx_bilhetes_wpp_id_bilhetes_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_bilhetes_wpp_id_bilhetes_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_bilhetes_wpp_id_bilhetes_seq OWNER TO contacte;

--
-- Name: pbx_bilhetes_wpp_id_bilhetes_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_bilhetes_wpp_id_bilhetes_seq OWNED BY pbx_bilhetes_wpp.id_bilhetes;


--
-- Name: pbx_bloco_de_notas_TextoCod_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE "pbx_bloco_de_notas_TextoCod_seq"
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public."pbx_bloco_de_notas_TextoCod_seq" OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_bloco_de_notas; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_bloco_de_notas (
    "TextoCod" integer DEFAULT nextval('"pbx_bloco_de_notas_TextoCod_seq"'::regclass) NOT NULL,
    "Conteudo" text NOT NULL,
    telefone integer,
    matricula integer NOT NULL,
    "Data" timestamp(0) with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_bloco_de_notas OWNER TO contacte;

--
-- Name: pbx_bloco_de_notas_textocod_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_bloco_de_notas_textocod_seq
    START WITH 1
    INCREMENT BY 1
    MAXVALUE 2147483647
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_bloco_de_notas_textocod_seq OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_cadastro_funcoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cadastro_funcoes (
    id integer NOT NULL,
    nome_tabela character varying(120),
    nome_display character varying(120),
    status integer DEFAULT 1
);


ALTER TABLE public.pbx_cadastro_funcoes OWNER TO contacte;

--
-- Name: pbx_cadastro_funcoes_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cadastro_funcoes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cadastro_funcoes_id_seq OWNER TO contacte;

--
-- Name: pbx_cadastro_funcoes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cadastro_funcoes_id_seq OWNED BY pbx_cadastro_funcoes.id;


--
-- Name: pbx_callback; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_callback (
    id integer NOT NULL,
    descricao character varying(100),
    opcao character varying(100),
    acao character varying(100),
    opcao1 character varying(100),
    acao1 character varying(100),
    ramal_saida character varying(32),
    tempo_desligamento integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_callback OWNER TO contacte;

--
-- Name: pbx_callback_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_callback_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_callback_id_seq OWNER TO contacte;

--
-- Name: pbx_callback_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_callback_id_seq OWNED BY pbx_callback.id;


--
-- Name: pbx_callback_numeros; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_callback_numeros (
    id integer NOT NULL,
    numero character varying(20),
    id_callback integer NOT NULL
);


ALTER TABLE public.pbx_callback_numeros OWNER TO contacte;

--
-- Name: pbx_callback_numeros_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_callback_numeros_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_callback_numeros_id_seq OWNER TO contacte;

--
-- Name: pbx_callback_numeros_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_callback_numeros_id_seq OWNED BY pbx_callback_numeros.id;


--
-- Name: pbx_campanha; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha (
    cmp_id integer NOT NULL,
    cmp_descricao character varying(120) NOT NULL,
    cmp_ramal character varying(100),
    id_dac integer NOT NULL,
    cmp_aguarda_agente integer DEFAULT 0 NOT NULL,
    cmp_numero_ligacoes_agente integer DEFAULT 1 NOT NULL,
    cmp_numero_rediscagem integer DEFAULT 1 NOT NULL,
    cmp_tempo_rediscagem integer DEFAULT 1 NOT NULL,
    cmp_pid integer,
    cmp_tipo_campanha integer DEFAULT 1 NOT NULL,
    cmp_status integer DEFAULT 1 NOT NULL,
    id_usuario integer,
    ident_proc text,
    data_registro timestamp without time zone DEFAULT now() NOT NULL,
    cmp_dados_envio text,
    cmp_seletiva smallint DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_campanha OWNER TO contacte;

--
-- Name: pbx_campanha_cmp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_cmp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_cmp_id_seq OWNER TO contacte;

--
-- Name: pbx_campanha_cmp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_cmp_id_seq OWNED BY pbx_campanha.cmp_id;


--
-- Name: pbx_campanha_contato; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_contato (
    cont_id integer NOT NULL,
    cmp_id integer NOT NULL,
    list_id integer NOT NULL,
    cont_identificador character varying(256) NOT NULL,
    cont_param1 character varying(256),
    cont_param2 character varying(256),
    cont_param3 character varying(256),
    cont_param4 character varying(256),
    cont_param5 character varying(256),
    cont_discado integer DEFAULT 0,
    cont_peso integer DEFAULT 0,
    data_reg timestamp without time zone DEFAULT now(),
    cont_status integer DEFAULT 1 NOT NULL,
    cont_fechamento timestamp without time zone,
    cont_msg character varying(1024),
    matricula character varying(10),
    conf_matricula_exclusiva character varying(4)
);


ALTER TABLE public.pbx_campanha_contato OWNER TO contacte;

--
-- Name: pbx_campanha_contato_cont_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_contato_cont_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_contato_cont_id_seq OWNER TO contacte;

--
-- Name: pbx_campanha_contato_cont_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_contato_cont_id_seq OWNED BY pbx_campanha_contato.cont_id;


--
-- Name: pbx_campanha_contato_display; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_contato_display (
    disp_id integer NOT NULL,
    cmp_id integer NOT NULL,
    list_id integer NOT NULL,
    disp_param1 character varying(100),
    disp_param2 character varying(100),
    disp_param3 character varying(100),
    disp_param4 character varying(100),
    disp_param5 character varying(100),
    disp_identificador character varying(200),
    disp_telefones character varying(100)
);


ALTER TABLE public.pbx_campanha_contato_display OWNER TO contacte;

--
-- Name: pbx_campanha_contato_display_disp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_contato_display_disp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_contato_display_disp_id_seq OWNER TO contacte;

--
-- Name: pbx_campanha_contato_display_disp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_contato_display_disp_id_seq OWNED BY pbx_campanha_contato_display.disp_id;


--
-- Name: pbx_campanha_contato_fone; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_contato_fone (
    conf_id integer NOT NULL,
    cmp_id integer NOT NULL,
    list_id integer NOT NULL,
    cont_id integer NOT NULL,
    conf_fone character varying(128) NOT NULL,
    conf_status character varying(50) DEFAULT 0,
    conf_callfile character varying(100),
    conf_data timestamp without time zone DEFAULT now(),
    conf_status_lista integer DEFAULT 1 NOT NULL,
    conf_uid character varying(32),
    conf_protocolo character varying(32),
    conf_agente_matricula character varying(10),
    matricula character varying(10),
    conf_discado integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_campanha_contato_fone OWNER TO contacte;

--
-- Name: pbx_campanha_contato_fone_conf_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_contato_fone_conf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_contato_fone_conf_id_seq OWNER TO contacte;

--
-- Name: pbx_campanha_contato_fone_conf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_contato_fone_conf_id_seq OWNED BY pbx_campanha_contato_fone.conf_id;


--
-- Name: pbx_campanha_contato_status; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_contato_status (
    ctst_id integer NOT NULL,
    ctst_nome character varying(60),
    ctst_status integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_campanha_contato_status OWNER TO contacte;

--
-- Name: pbx_campanha_lista; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_lista (
    list_id integer NOT NULL,
    cmp_id integer NOT NULL,
    list_nome character varying(254),
    list_file character varying(254),
    list_file_dados text,
    list_status integer DEFAULT 1 NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    id_usuario integer,
    list_dados_envio text,
    list_id_tpl integer
);


ALTER TABLE public.pbx_campanha_lista OWNER TO contacte;

--
-- Name: pbx_campanha_lista_list_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_lista_list_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_lista_list_id_seq OWNER TO contacte;

--
-- Name: pbx_campanha_lista_list_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_lista_list_id_seq OWNED BY pbx_campanha_lista.list_id;


--
-- Name: pbx_campanha_operacao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_operacao (
    cmpo_id integer NOT NULL,
    matricula character varying(4),
    cmpo_data date DEFAULT (now())::date NOT NULL,
    cmpo_status integer DEFAULT 0 NOT NULL,
    cmp_id integer,
    list_id integer,
    cont_id integer,
    conf_id integer,
    cmp_descricao character varying(100),
    list_nome character varying(100),
    cont_identificador character varying(256),
    cont_param1 character varying(256),
    cont_param2 character varying(256),
    cont_param3 character varying(256),
    cont_param4 character varying(256),
    cont_param5 character varying(256),
    disp_param1 character varying(100),
    disp_param2 character varying(100),
    disp_param3 character varying(100),
    disp_param4 character varying(100),
    disp_param5 character varying(100),
    conf_fone character varying(30),
    lista_fones_discador character varying(4096),
    cmpo_inicio timestamp without time zone DEFAULT now() NOT NULL,
    cmpo_fim timestamp without time zone,
    cmpo_msg character varying(1024),
    carrega_fone integer DEFAULT 0 NOT NULL,
    discagem_inicial integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_campanha_operacao OWNER TO contacte;

--
-- Name: pbx_campanha_operacao_cmpo_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_operacao_cmpo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_operacao_cmpo_id_seq OWNER TO contacte;

--
-- Name: pbx_campanha_operacao_cmpo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_operacao_cmpo_id_seq OWNED BY pbx_campanha_operacao.cmpo_id;


--
-- Name: pbx_campanha_parametros; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_parametros (
    id_param integer NOT NULL,
    host_param character varying(150),
    user_param character varying(50),
    password_param character varying(150),
    port_param character varying(10),
    secure_param character varying(10),
    charset_param character varying(10),
    auth_param character varying(10),
    from_param character varying(150),
    update_reg timestamp without time zone DEFAULT now(),
    data_reg timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_campanha_parametros OWNER TO contacte;

--
-- Name: pbx_campanha_parametros_id_param_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_parametros_id_param_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_parametros_id_param_seq OWNER TO contacte;

--
-- Name: pbx_campanha_parametros_id_param_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_parametros_id_param_seq OWNED BY pbx_campanha_parametros.id_param;


--
-- Name: pbx_campanha_referencia_recicla; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_referencia_recicla (
    ctst_id integer NOT NULL
);


ALTER TABLE public.pbx_campanha_referencia_recicla OWNER TO contacte;

--
-- Name: pbx_campanha_referencia_status; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_referencia_status (
    ctst_id integer NOT NULL
);


ALTER TABLE public.pbx_campanha_referencia_status OWNER TO contacte;

--
-- Name: pbx_campanha_registro; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_registro (
    id_cmpr integer NOT NULL,
    list_id integer NOT NULL,
    cont_id integer NOT NULL,
    conf_id integer NOT NULL,
    ctp_id integer NOT NULL,
    matricula_exclusiva character varying(4) NOT NULL,
    contato_cmpr character varying(200) NOT NULL,
    status_cmpr integer,
    user_reg integer NOT NULL,
    inicio_cmpr timestamp without time zone DEFAULT now(),
    fim_cmpr timestamp without time zone DEFAULT now(),
    data_cmpr timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_campanha_registro OWNER TO contacte;

--
-- Name: pbx_campanha_registro_id_cmpr_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_registro_id_cmpr_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_registro_id_cmpr_seq OWNER TO contacte;

--
-- Name: pbx_campanha_registro_id_cmpr_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_registro_id_cmpr_seq OWNED BY pbx_campanha_registro.id_cmpr;


--
-- Name: pbx_campanha_status; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_status (
    cpst_id integer NOT NULL,
    cpst_nome character varying(60),
    cpst_status integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_campanha_status OWNER TO contacte;

--
-- Name: pbx_campanha_template; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_template (
    id_tpl integer NOT NULL,
    nome_tpl character varying(100) NOT NULL,
    path_tpl character varying(255) NOT NULL,
    title_tpl character varying(255),
    subject_tpl character varying(255),
    ctp_id integer NOT NULL,
    data_reg timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_campanha_template OWNER TO contacte;

--
-- Name: pbx_campanha_template_id_tpl_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_template_id_tpl_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_template_id_tpl_seq OWNER TO contacte;

--
-- Name: pbx_campanha_template_id_tpl_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_template_id_tpl_seq OWNED BY pbx_campanha_template.id_tpl;


--
-- Name: pbx_campanha_tipo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_tipo (
    ctp_id integer NOT NULL,
    ctp_descricao character varying(128) NOT NULL,
    ctp_parametros text,
    user_reg integer,
    data_reg timestamp(6) without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_campanha_tipo OWNER TO contacte;

--
-- Name: pbx_campanha_tipo_ctp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_campanha_tipo_ctp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_campanha_tipo_ctp_id_seq OWNER TO contacte;

--
-- Name: pbx_campanha_tipo_ctp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_campanha_tipo_ctp_id_seq OWNED BY pbx_campanha_tipo.ctp_id;


--
-- Name: pbx_campanha_usuarios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_campanha_usuarios (
    cmp_id integer NOT NULL,
    matricula character varying(4) NOT NULL
);


ALTER TABLE public.pbx_campanha_usuarios OWNER TO contacte;

--
-- Name: pbx_canais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_canais (
    uniqueid character varying(32) NOT NULL,
    channel character varying(80) NOT NULL,
    state character varying(20),
    calleridnum character varying(32),
    calleridname character varying(32),
    dispositivo character varying(32),
    link character varying(80)
);


ALTER TABLE public.pbx_canais OWNER TO contacte;

--
-- Name: pbx_cel; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cel (
    id bigint NOT NULL,
    eventtype character varying(32) NOT NULL,
    eventtime timestamp without time zone NOT NULL,
    userdeftype character varying(256) NOT NULL,
    cid_name character varying(128) NOT NULL,
    cid_num character varying(128) NOT NULL,
    cid_ani character varying(128) NOT NULL,
    cid_rdnis character varying(128) NOT NULL,
    cid_dnid character varying(128) NOT NULL,
    exten character varying(128) NOT NULL,
    context character varying(128) NOT NULL,
    channame character varying(128) NOT NULL,
    appname character varying(128) NOT NULL,
    appdata character varying(128) NOT NULL,
    amaflags integer NOT NULL,
    accountcode character varying(32) NOT NULL,
    peeraccount character varying(32) NOT NULL,
    uniqueid character varying(160) NOT NULL,
    linkedid character varying(160) NOT NULL,
    userfield character varying(256) NOT NULL,
    peer character varying(128) NOT NULL
);


ALTER TABLE public.pbx_cel OWNER TO contacte;

--
-- Name: pbx_cel_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cel_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cel_id_seq OWNER TO contacte;

--
-- Name: pbx_cel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cel_id_seq OWNED BY pbx_cel.id;


--
-- Name: pbx_centro_custo_cc_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_centro_custo_cc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_centro_custo_cc_id_seq OWNER TO contacte;

--
-- Name: pbx_centro_custo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_centro_custo (
    cc_id integer DEFAULT nextval('pbx_centro_custo_cc_id_seq'::regclass) NOT NULL,
    empresa integer,
    departamento integer,
    cc_descricao character varying(80),
    cc_status integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_centro_custo OWNER TO contacte;

--
-- Name: pbx_chamada_ramal; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_chamada_ramal (
    chdr_id bigint NOT NULL,
    chdr_data date DEFAULT (now())::date NOT NULL,
    chdr_inicio timestamp without time zone DEFAULT now() NOT NULL,
    uniqueid character varying(32),
    chdr_channel character varying(16) NOT NULL,
    chdr_numero character varying(32) NOT NULL,
    chrd_direcao_chamada character(1),
    chdr_status character varying(16),
    chdr_fim timestamp without time zone,
    chdr_log character varying(1024)
);


ALTER TABLE public.pbx_chamada_ramal OWNER TO contacte;

--
-- Name: pbx_chamada_ramal_chdr_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_chamada_ramal_chdr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_chamada_ramal_chdr_id_seq OWNER TO contacte;

--
-- Name: pbx_chamada_ramal_chdr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_chamada_ramal_chdr_id_seq OWNED BY pbx_chamada_ramal.chdr_id;


--
-- Name: pbx_chefe_secretaria; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_chefe_secretaria (
    numero character varying(20) NOT NULL,
    excecao character varying(30) NOT NULL
);


ALTER TABLE public.pbx_chefe_secretaria OWNER TO contacte;

--
-- Name: pbx_classifica_dacs; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_classifica_dacs (
    id_dac integer NOT NULL,
    clas_id integer NOT NULL
);


ALTER TABLE public.pbx_classifica_dacs OWNER TO contacte;

--
-- Name: pbx_classifica_reg_wpp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_classifica_reg_wpp (
    matricula character varying(4) NOT NULL,
    clas_id integer NOT NULL,
    clit_id integer NOT NULL,
    id_bilhetes character varying(32) NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    contrib_id integer,
    id_dac integer,
    mun_id integer,
    integra_vendas integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_classifica_reg_wpp OWNER TO contacte;

--
-- Name: pbx_cliente; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente (
    client_id bigint NOT NULL,
    client_ref_id character varying(256),
    client_out_id bigint,
    client_processo character varying(64),
    client_data_processo timestamp without time zone,
    client_tipo_documento character varying(16) DEFAULT 'CNPJ'::character varying NOT NULL,
    client_documento character varying(64),
    client_status character varying(32),
    client_razao_social character varying(128) NOT NULL,
    client_nome_fantasia character varying(128),
    client_endereco character varying(256),
    client_municipio character varying(128),
    client_uf character varying(128),
    client_telefone character varying(32),
    client_celular character varying(32),
    client_email character varying(128),
    client_nome_contato character varying(128),
    client_fone_contato character varying(32),
    client_celular_contato character varying(32),
    client_email_contato character varying(128),
    client_obs text,
    client_data_contato timestamp without time zone,
    client_user_contato character varying(32),
    client_tipo_contato character varying(32),
    client_update timestamp without time zone,
    client_integra timestamp without time zone,
    client_agendamento timestamp without time zone,
    client_class integer,
    clo_id integer,
    csg_id integer,
    cmp_id integer,
    list_id integer,
    cont_id integer,
    user_reg integer,
    data_reg timestamp(6) without time zone DEFAULT now() NOT NULL,
    data_lead timestamp without time zone,
    data_cliente timestamp without time zone
);


ALTER TABLE public.pbx_cliente OWNER TO contacte;

--
-- Name: pbx_cliente_anotacoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_anotacoes (
    cla_id integer NOT NULL,
    client_id bigint NOT NULL,
    cla_anotacao text NOT NULL,
    user_reg integer,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_cliente_anotacoes OWNER TO contacte;

--
-- Name: pbx_cliente_anotacoes_cla_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_anotacoes_cla_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_anotacoes_cla_id_seq OWNER TO contacte;

--
-- Name: pbx_cliente_anotacoes_cla_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_anotacoes_cla_id_seq OWNED BY pbx_cliente_anotacoes.cla_id;


--
-- Name: pbx_cliente_audio; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_audio (
    clau_id integer NOT NULL,
    client_id integer NOT NULL,
    uid character varying(32) NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_cliente_audio OWNER TO contacte;

--
-- Name: pbx_cliente_audio_clau_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_audio_clau_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_audio_clau_id_seq OWNER TO contacte;

--
-- Name: pbx_cliente_audio_clau_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_audio_clau_id_seq OWNED BY pbx_cliente_audio.clau_id;


--
-- Name: pbx_cliente_client_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_client_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_client_id_seq OWNER TO contacte;

--
-- Name: pbx_cliente_client_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_client_id_seq OWNED BY pbx_cliente.client_id;


--
-- Name: pbx_cliente_contato; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_contato (
    clc_id integer NOT NULL,
    client_id bigint NOT NULL,
    clc_contato_principal integer DEFAULT 0 NOT NULL,
    clc_nome character varying(128) NOT NULL,
    clc_email character varying(128),
    clc_fone character varying(32),
    clc_whatsapp character varying(32),
    clc_telegram character varying(32),
    clc_sms character varying(32),
    user_reg integer,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_cliente_contato OWNER TO contacte;

--
-- Name: pbx_cliente_contato_clc_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_contato_clc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_contato_clc_id_seq OWNER TO contacte;

--
-- Name: pbx_cliente_contato_clc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_contato_clc_id_seq OWNED BY pbx_cliente_contato.clc_id;


--
-- Name: pbx_cliente_fornecedor; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_fornecedor (
    cfr_id integer NOT NULL,
    cfr_razao_social character varying(128) NOT NULL,
    cfr_contato character varying(128),
    cfr_telefone character varying(32),
    cfr_obs character varying(255),
    user_reg integer,
    data_reg timestamp(6) without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_cliente_fornecedor OWNER TO contacte;

--
-- Name: pbx_cliente_fornecedor_cfr_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_fornecedor_cfr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_fornecedor_cfr_id_seq OWNER TO contacte;

--
-- Name: pbx_cliente_fornecedor_cfr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_fornecedor_cfr_id_seq OWNED BY pbx_cliente_fornecedor.cfr_id;


--
-- Name: pbx_cliente_origem; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_origem (
    clo_id integer NOT NULL,
    clo_titulo character varying(64) NOT NULL,
    clo_descricao character varying(256),
    cfr_id integer NOT NULL,
    user_reg integer,
    data_reg timestamp(6) without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_cliente_origem OWNER TO contacte;

--
-- Name: pbx_cliente_origem_clo_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_origem_clo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_origem_clo_id_seq OWNER TO contacte;

--
-- Name: pbx_cliente_origem_clo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_origem_clo_id_seq OWNED BY pbx_cliente_origem.clo_id;


--
-- Name: pbx_cliente_referencia_vendedor; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_referencia_vendedor (
    id_ref_vendedor integer NOT NULL,
    cod_vendedor integer NOT NULL,
    matricula character varying(10) NOT NULL,
    data_reg timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_cliente_referencia_vendedor OWNER TO contacte;

--
-- Name: pbx_cliente_referencia_vendedor_id_ref_vendedor_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_referencia_vendedor_id_ref_vendedor_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_referencia_vendedor_id_ref_vendedor_seq OWNER TO contacte;

--
-- Name: pbx_cliente_referencia_vendedor_id_ref_vendedor_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_referencia_vendedor_id_ref_vendedor_seq OWNED BY pbx_cliente_referencia_vendedor.id_ref_vendedor;


--
-- Name: pbx_cliente_remover; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_remover (
    client_id bigint,
    client_ref_id character varying(256),
    client_out_id bigint,
    client_processo character varying(64),
    client_data_processo timestamp without time zone,
    client_tipo_documento character varying(16),
    client_documento character varying(64),
    client_status character varying(32),
    client_razao_social character varying(128),
    client_nome_fantasia character varying(128),
    client_endereco character varying(256),
    client_municipio character varying(128),
    client_uf character varying(128),
    client_telefone character varying(32),
    client_celular character varying(32),
    client_email character varying(128),
    client_nome_contato character varying(128),
    client_fone_contato character varying(32),
    client_celular_contato character varying(32),
    client_email_contato character varying(128),
    client_obs text,
    client_data_contato timestamp without time zone,
    client_user_contato character varying(32),
    client_tipo_contato character varying(32),
    client_update timestamp without time zone,
    client_integra timestamp without time zone,
    client_agendamento date,
    client_class integer,
    clo_id integer,
    csg_id integer,
    cmp_id integer,
    list_id integer,
    cont_id integer,
    user_reg integer,
    data_reg timestamp(6) without time zone
);


ALTER TABLE public.pbx_cliente_remover OWNER TO contacte;

--
-- Name: pbx_cliente_segmento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cliente_segmento (
    csg_id integer NOT NULL,
    csg_descricao character varying(128) NOT NULL,
    user_reg integer,
    data_reg timestamp(6) without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_cliente_segmento OWNER TO contacte;

--
-- Name: pbx_cliente_segmento_csg_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cliente_segmento_csg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cliente_segmento_csg_id_seq OWNER TO contacte;

--
-- Name: pbx_cliente_segmento_csg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_cliente_segmento_csg_id_seq OWNED BY pbx_cliente_segmento.csg_id;


SET default_with_oids = true;

--
-- Name: pbx_conf_monitor; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_conf_monitor (
    servidor_email character varying(100),
    email_principal character varying(100),
    senha_principal character varying(100),
    de_email character varying(100),
    de_nome character varying(100),
    usuarios character varying(100),
    cabecalho character varying(100),
    recebedores character varying(1000)
);


ALTER TABLE public.pbx_conf_monitor OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_conf_padrao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_conf_padrao (
    caminho_backup character varying(100),
    caminho_producao character varying(100),
    caminho_musicas character varying(100),
    url_musicas character varying(100),
    url_asterisk character varying(100),
    caminho_musicas_ura character varying(100),
    usuario_servidor character varying(50),
    senha_servidor character varying(50),
    path_som character varying(100),
    porta_servidor integer DEFAULT 22 NOT NULL,
    id_conf integer NOT NULL
);


ALTER TABLE public.pbx_conf_padrao OWNER TO contacte;

--
-- Name: pbx_conf_padrao_id_conf_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_conf_padrao_id_conf_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_conf_padrao_id_conf_seq OWNER TO contacte;

--
-- Name: pbx_conf_padrao_id_conf_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_conf_padrao_id_conf_seq OWNED BY pbx_conf_padrao.id_conf;


--
-- Name: pbx_conferencia_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_conferencia_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_conferencia_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_conferencia; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_conferencia (
    id integer DEFAULT nextval('pbx_conferencia_id_seq'::regclass) NOT NULL,
    numero character varying(100),
    limite integer,
    grava character(1),
    senha_usuario character varying(10),
    senha_admin character varying(10),
    encerra_sem_admin character(1),
    silencioso character(1),
    anuncia_conta character(1),
    anuncia_entrada character(1),
    musica_espera character(1),
    habilita_menu character(1),
    anuncio character varying(100)
);


ALTER TABLE public.pbx_conferencia OWNER TO contacte;

--
-- Name: pbx_config; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_config (
    ip_pbx inet,
    ip_bd inet,
    ip_audios inet,
    porta_pbx integer,
    porta_bd integer,
    usuario_pbx character varying(50),
    senha_pbx character varying(50),
    usuario_bd character varying(50),
    senha_bd character varying(50),
    autenticacao character varying(10),
    proxima_matricula integer,
    sleep_login integer
);


ALTER TABLE public.pbx_config OWNER TO contacte;

--
-- Name: pbx_confmail_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_confmail_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_confmail_id_seq OWNER TO contacte;

--
-- Name: pbx_confmail; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_confmail (
    id integer DEFAULT nextval('pbx_confmail_id_seq'::regclass) NOT NULL,
    conta character varying(100),
    porta integer,
    timeout character varying(3),
    protocolo character varying(10),
    dominio character varying(100),
    tsl character varying(3),
    tsl_certificado character varying(100),
    tsl_check character varying(3),
    logfile character varying(100),
    hosts character varying(100),
    de character varying(100),
    auth character varying(100),
    usuario character varying(100),
    senha character varying(100),
    padrao character varying(1)
);


ALTER TABLE public.pbx_confmail OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_consulta_ddd; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_consulta_ddd (
    id integer NOT NULL,
    codigo_ddd integer,
    nome_municipio character varying(50) NOT NULL,
    uf character(2) NOT NULL,
    prefixo integer NOT NULL,
    inicial integer,
    final integer
);


ALTER TABLE public.pbx_consulta_ddd OWNER TO contacte;

--
-- Name: pbx_contextos_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_contextos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_contextos_id_seq OWNER TO contacte;

--
-- Name: pbx_contextos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos (
    id integer DEFAULT nextval('pbx_contextos_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    recorte character varying(10),
    acrescenta character varying(15),
    acao character varying(100),
    opcao character varying(100),
    inclui_padrao character varying(1),
    direcao_chamada character(1) DEFAULT 'E'::bpchar NOT NULL
);


ALTER TABLE public.pbx_contextos OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_contextos_canais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos_canais (
    id integer NOT NULL,
    id_contexto integer NOT NULL,
    canal character varying(100),
    id_modelo integer
);


ALTER TABLE public.pbx_contextos_canais OWNER TO contacte;

--
-- Name: pbx_contextos_canais_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_contextos_canais_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_contextos_canais_id_seq OWNER TO contacte;

--
-- Name: pbx_contextos_canais_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_contextos_canais_id_seq OWNED BY pbx_contextos_canais.id;


SET default_with_oids = false;

--
-- Name: pbx_contextos_canais_tmp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos_canais_tmp (
    id integer NOT NULL,
    id_contexto integer NOT NULL,
    canal character varying(100),
    id_modelo integer
);


ALTER TABLE public.pbx_contextos_canais_tmp OWNER TO contacte;

--
-- Name: pbx_contextos_canais_tmp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_contextos_canais_tmp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_contextos_canais_tmp_id_seq OWNER TO contacte;

--
-- Name: pbx_contextos_canais_tmp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_contextos_canais_tmp_id_seq OWNED BY pbx_contextos_canais_tmp.id;


SET default_with_oids = true;

--
-- Name: pbx_contextos_modelos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos_modelos (
    id integer NOT NULL,
    id_contexto integer NOT NULL,
    modelo character varying(100),
    recorte character varying(10),
    acrescenta character varying(15),
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_contextos_modelos OWNER TO contacte;

--
-- Name: pbx_contextos_modelos_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_contextos_modelos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_contextos_modelos_id_seq OWNER TO contacte;

--
-- Name: pbx_contextos_modelos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_contextos_modelos_id_seq OWNED BY pbx_contextos_modelos.id;


SET default_with_oids = false;

--
-- Name: pbx_contextos_modelos_tmp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos_modelos_tmp (
    id integer NOT NULL,
    id_contexto integer NOT NULL,
    modelo character varying(100),
    recorte character varying(10),
    acrescenta character varying(15),
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_contextos_modelos_tmp OWNER TO contacte;

--
-- Name: pbx_contextos_modelos_tmp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_contextos_modelos_tmp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_contextos_modelos_tmp_id_seq OWNER TO contacte;

--
-- Name: pbx_contextos_modelos_tmp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_contextos_modelos_tmp_id_seq OWNED BY pbx_contextos_modelos_tmp.id;


--
-- Name: pbx_contextos_opcoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos_opcoes (
    id integer NOT NULL,
    opcao character varying(100) NOT NULL,
    acao character varying(100) NOT NULL,
    id_modelo integer NOT NULL,
    id_contexto integer,
    acao_text character varying(100)
);


ALTER TABLE public.pbx_contextos_opcoes OWNER TO contacte;

--
-- Name: pbx_contextos_opcoes_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_contextos_opcoes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_contextos_opcoes_id_seq OWNER TO contacte;

--
-- Name: pbx_contextos_opcoes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_contextos_opcoes_id_seq OWNED BY pbx_contextos_opcoes.id;


--
-- Name: pbx_contextos_opcoes_tmp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos_opcoes_tmp (
    id integer NOT NULL,
    id_contexto integer,
    opcao character varying(100) NOT NULL,
    acao character varying(100) NOT NULL,
    id_modelo integer,
    acao_text character varying(100)
);


ALTER TABLE public.pbx_contextos_opcoes_tmp OWNER TO contacte;

--
-- Name: pbx_contextos_opcoes_tmp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_contextos_opcoes_tmp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_contextos_opcoes_tmp_id_seq OWNER TO contacte;

--
-- Name: pbx_contextos_opcoes_tmp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_contextos_opcoes_tmp_id_seq OWNED BY pbx_contextos_opcoes_tmp.id;


--
-- Name: pbx_contextos_operacoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_contextos_operacoes (
    ctop_tipo character varying(30) NOT NULL,
    ctop_contexto character varying(100) NOT NULL
);


ALTER TABLE public.pbx_contextos_operacoes OWNER TO contacte;

--
-- Name: pbx_contribuinte; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_contribuinte (
    contrib_id integer NOT NULL,
    contrib_nome character varying(80) NOT NULL,
    contrib_email character varying(50),
    contrib_tipo integer DEFAULT 1 NOT NULL,
    contrib_tipo_id character varying(128),
    contrib_fone character varying(18),
    contrib_data timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_contribuinte OWNER TO postgres;

--
-- Name: pbx_controle_acesso; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_controle_acesso (
    acs_id bigint NOT NULL,
    acs_data_ini timestamp without time zone DEFAULT now(),
    acs_data_fim timestamp without time zone,
    acs_data_ultacess timestamp without time zone DEFAULT now(),
    acs_prog_ultacess integer DEFAULT 0 NOT NULL,
    acs_sessao character varying(50),
    acs_ip character varying(32),
    acs_login character varying(128) NOT NULL,
    acs_user_id integer,
    acs_erro integer DEFAULT 0,
    acs_log text
);


ALTER TABLE public.pbx_controle_acesso OWNER TO contacte;

--
-- Name: pbx_controle_acesso_acs_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_controle_acesso_acs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_controle_acesso_acs_id_seq OWNER TO contacte;

--
-- Name: pbx_controle_acesso_acs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_controle_acesso_acs_id_seq OWNED BY pbx_controle_acesso.acs_id;


--
-- Name: pbx_controle_acesso_item; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_controle_acesso_item (
    acsi_id bigint NOT NULL,
    acs_id bigint NOT NULL,
    acsi_prog integer,
    acsi_data timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_controle_acesso_item OWNER TO contacte;

--
-- Name: pbx_controle_acesso_item_acsi_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_controle_acesso_item_acsi_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_controle_acesso_item_acsi_id_seq OWNER TO contacte;

--
-- Name: pbx_controle_acesso_item_acsi_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_controle_acesso_item_acsi_id_seq OWNED BY pbx_controle_acesso_item.acsi_id;


--
-- Name: pbx_cs_usuarios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cs_usuarios (
    id integer NOT NULL,
    nome character varying(50) NOT NULL,
    apelido character varying(20) NOT NULL,
    matricula character varying(16) NOT NULL,
    empresa integer NOT NULL,
    departamento integer NOT NULL,
    local_fixo boolean DEFAULT false,
    local_celular boolean DEFAULT false,
    inter_fixo boolean DEFAULT false,
    inter_celular boolean DEFAULT false,
    internacional boolean DEFAULT false,
    lig_0300 boolean DEFAULT false,
    lig_0500 boolean DEFAULT false,
    lig_0303 boolean DEFAULT false,
    lig_0800 boolean DEFAULT false,
    lig_0900 boolean DEFAULT false,
    todos_lig character varying(100),
    perm_especial boolean DEFAULT false,
    temporizacao integer DEFAULT 0,
    tag integer DEFAULT 0 NOT NULL,
    data_atualizacao timestamp(0) with time zone DEFAULT now(),
    status character(1) DEFAULT 'a'::bpchar NOT NULL,
    senha character varying(10) DEFAULT 1234 NOT NULL,
    origem character varying(30),
    grava_ligacao integer DEFAULT 0,
    saldo_prepago numeric(12,4) DEFAULT 0,
    habilita_prepago integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_cs_usuarios OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_cs_usuarios_ddd; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_cs_usuarios_ddd (
    id_ddd integer NOT NULL,
    id_usuario integer NOT NULL
);


ALTER TABLE public.pbx_cs_usuarios_ddd OWNER TO contacte;

--
-- Name: pbx_cs_usuarios_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cs_usuarios_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cs_usuarios_id_seq OWNER TO contacte;

--
-- Name: pbx_cs_usuarios_matricula_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cs_usuarios_matricula_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cs_usuarios_matricula_seq OWNER TO contacte;

--
-- Name: pbx_cs_usuarios_matricula_seq1; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_cs_usuarios_matricula_seq1
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_cs_usuarios_matricula_seq1 OWNER TO contacte;

--
-- Name: pbx_dac_usuario_id_dac_usu_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_dac_usuario_id_dac_usu_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_dac_usuario_id_dac_usu_seq OWNER TO postgres;

--
-- Name: pbx_dac_usuario; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_dac_usuario (
    id_dac_usu integer DEFAULT nextval('pbx_dac_usuario_id_dac_usu_seq'::regclass) NOT NULL,
    id_usuario integer NOT NULL,
    id_dac integer NOT NULL,
    padrao boolean NOT NULL,
    flag integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_dac_usuario OWNER TO postgres;

--
-- Name: pbx_dacs_api; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_dacs_api AS
    SELECT pbx_queues_grupos.id, pbx_queues_grupos.nome, pbx_queues_grupos.numero, pbx_queues_grupos.status FROM pbx_queues_grupos;


ALTER TABLE public.pbx_dacs_api OWNER TO contacte;

--
-- Name: pbx_dacs_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_dacs_id_seq
    START WITH 1
    INCREMENT BY 1
    MAXVALUE 2147483647
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_dacs_id_seq OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_dahdi; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_dahdi (
    id integer NOT NULL,
    senha integer,
    dispositivo character varying(250),
    voicemail character varying(20),
    senha_v character varying(20),
    usuario_v character varying(20),
    contexto character varying(20),
    grupo character varying(20),
    imediate character varying(20),
    accountcode character varying(100),
    capturar character varying(100),
    espera character varying(1),
    sigame_interno character varying(20),
    sigame_externo character varying(20),
    sigame_naoatende character varying(20),
    sigame_ocupado character varying(20),
    gravacao_chamada character varying(1),
    musica_espera character varying(100),
    nao_pertube character varying(1),
    cadeado character varying(1),
    gravacao_saida character varying(1),
    senha_facilidade character varying(100),
    identificador character varying(100),
    numero character varying(10),
    identificador2 character varying(100),
    conta_senha character varying(1) DEFAULT 'V'::character varying NOT NULL,
    ramalsecretaria character varying(20),
    saldo_prepago numeric(12,4) DEFAULT 0,
    habilita_prepago integer DEFAULT 0 NOT NULL,
    ring_time character varying(100),
    timeout character varying(16)
);


ALTER TABLE public.pbx_dahdi OWNER TO simplesip;

--
-- Name: pbx_dahdi_id_seq; Type: SEQUENCE; Schema: public; Owner: simplesip
--

CREATE SEQUENCE pbx_dahdi_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_dahdi_id_seq OWNER TO simplesip;

--
-- Name: pbx_dahdi_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: simplesip
--

ALTER SEQUENCE pbx_dahdi_id_seq OWNED BY pbx_dahdi.id;


--
-- Name: pbx_dbtype; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_dbtype (
    db_prefix character varying(10) NOT NULL,
    db_description character varying(80) NOT NULL,
    db_obs character varying(1024)
);


ALTER TABLE public.pbx_dbtype OWNER TO contacte;

--
-- Name: pbx_ddd_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_ddd_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_ddd_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_ddd; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_ddd (
    id integer DEFAULT nextval('pbx_ddd_id_seq'::regclass) NOT NULL,
    ddd numeric(2,0) NOT NULL,
    localidade character varying(100) NOT NULL,
    tag integer DEFAULT 0 NOT NULL,
    uf character varying(2)
);


ALTER TABLE public.pbx_ddd OWNER TO contacte;

--
-- Name: pbx_departamentos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_departamentos (
    id integer NOT NULL,
    nome_depto character varying(50) NOT NULL,
    empresa integer NOT NULL,
    tag integer DEFAULT 0 NOT NULL,
    origem character varying(30)
);


ALTER TABLE public.pbx_departamentos OWNER TO contacte;

--
-- Name: pbx_departamentos_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_departamentos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_departamentos_id_seq OWNER TO postgres;

--
-- Name: pbx_departamentos_id_seq1; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_departamentos_id_seq1
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_departamentos_id_seq1 OWNER TO contacte;

--
-- Name: pbx_dgv_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_dgv_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_dgv_id_seq OWNER TO contacte;

--
-- Name: pbx_dgv; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_dgv (
    id integer DEFAULT nextval('pbx_dgv_id_seq'::regclass) NOT NULL,
    senha integer,
    dispositivo character varying(250),
    voicemail character varying(20),
    senha_v character varying(20),
    usuario_v character varying(20),
    contexto character varying(20),
    grupo character varying(20),
    immediate character varying(20) DEFAULT NULL::character varying,
    accountcode character varying(100),
    capturar character varying(100),
    espera character varying(1),
    sigame_interno character varying(20),
    sigame_externo character varying(20),
    sigame_naoatende character varying(20),
    sigame_ocupado character varying(20),
    gravacao_chamada character varying(1),
    musica_espera character varying(100),
    nao_pertube character varying(1),
    cadeado character varying(1),
    gravacao_saida character varying(1),
    senha_facilidade character varying(100),
    identificador character varying(100),
    numero character varying(10),
    identificador2 character varying(100),
    conta_senha character varying(1) DEFAULT 'V'::character varying NOT NULL,
    ramalsecretaria character varying(20),
    saldo_prepago numeric(12,4) DEFAULT 0,
    habilita_prepago integer DEFAULT 0 NOT NULL,
    ring_time character varying(100),
    timeout character varying(16)
);


ALTER TABLE public.pbx_dgv OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_digivoice_allportsconfig; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_digivoice_allportsconfig (
    default_callprogress character varying(100),
    detectiontype integer,
    dialtype integer,
    afterdialpause character varying(10),
    ringbacktone1 character varying(10),
    ringbacktone2 character varying(10),
    ringbacktimes character varying(100),
    busytone1 character varying(10),
    busytone2 character varying(10),
    busytimes character varying(100),
    subchannelringtone1 character varying(10),
    subchannelringtone2 character varying(10),
    subchannelringtimes character varying(100)
);


ALTER TABLE public.pbx_digivoice_allportsconfig OWNER TO contacte;

--
-- Name: pbx_digivoice_e1config_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_digivoice_e1config_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_digivoice_e1config_id_seq OWNER TO contacte;

--
-- Name: pbx_digivoice_e1config; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_digivoice_e1config (
    id integer DEFAULT nextval('pbx_digivoice_e1config_id_seq'::regclass) NOT NULL,
    e1_sync character varying(100),
    use_crc4 character varying(100),
    span character varying(100),
    span2 character varying(100),
    cards character varying(100)
);


ALTER TABLE public.pbx_digivoice_e1config OWNER TO contacte;

--
-- Name: pbx_digivoice_general; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_digivoice_general (
    allow_slinear integer,
    allow_ulaw integer,
    allow_alaw integer,
    allow_gsm integer,
    consolelanguage character varying(10)
);


ALTER TABLE public.pbx_digivoice_general OWNER TO contacte;

--
-- Name: pbx_digivoice_grupos_group_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_digivoice_grupos_group_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_digivoice_grupos_group_seq OWNER TO contacte;

--
-- Name: pbx_digivoice_grupos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_digivoice_grupos (
    "group" integer DEFAULT nextval('pbx_digivoice_grupos_group_seq'::regclass) NOT NULL,
    ports character varying(10),
    signalling character varying(100),
    context character varying(100),
    language character varying(100),
    accountcode character varying(100),
    musiconhold character varying(100),
    tx_gain character varying(10),
    rx_gain character varying(10),
    echocan character varying(10),
    port_id character varying(10),
    echotraining character varying(10),
    callprogress character varying(100),
    silence_threshold character varying(100),
    relaxdtmf character varying(10),
    r2_country character varying(10),
    gen_dtmf character varying(10),
    gen_ringback character varying(10),
    gen_busy character varying(10),
    dtmf_to_asterisk character varying(10),
    faxdetection character varying(10),
    drop_tx_samples_factor character varying(10),
    max_digits_rx character varying(10),
    cid_pos character varying(10),
    category character varying(10),
    group_b_value character varying(10),
    b_subscriber_hangup character varying(10),
    wait_dialtone character varying(10),
    dialtone_timeout character varying(10),
    flash_min_time character varying(10),
    flash_max_time character varying(10),
    ring_type character varying(10),
    interdigit_timeout character varying(10),
    ccb_pass_through character varying(10),
    polarity character varying(10),
    immediate character varying(10),
    callgroup character varying(10),
    pickupgroup character varying(10),
    second_call_digits character varying(10),
    hide_number character varying(10),
    pin_number character varying(10),
    min_digits character varying(10),
    cid_type character varying(10),
    customcascfg character varying(100),
    ports_1 integer,
    ports_2 integer
);


ALTER TABLE public.pbx_digivoice_grupos OWNER TO contacte;

--
-- Name: pbx_digivoice_grupos__id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_digivoice_grupos__id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_digivoice_grupos__id_seq OWNER TO contacte;

--
-- Name: pbx_digivoice_grupos_; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_digivoice_grupos_ (
    id integer DEFAULT nextval('pbx_digivoice_grupos__id_seq'::regclass) NOT NULL,
    numero integer,
    portas character varying(10)
);


ALTER TABLE public.pbx_digivoice_grupos_ OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_digivoice_ramais_fxs; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_digivoice_ramais_fxs (
    id_grupo integer,
    tipo character varying(50),
    ramal character varying(20)
);


ALTER TABLE public.pbx_digivoice_ramais_fxs OWNER TO contacte;

--
-- Name: pbx_disa_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_disa_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_disa_id_seq OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_disa; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_disa (
    id integer DEFAULT nextval('pbx_disa_id_seq'::regclass) NOT NULL,
    numero character varying(20),
    descricao character varying(100),
    senha character varying(20),
    timeout integer DEFAULT 15,
    tempo_timeout integer DEFAULT 5,
    numeros character varying(100),
    opcao character varying(100),
    acao character varying(100),
    ligacao_externa integer DEFAULT 0 NOT NULL,
    ramal_saida character varying(32)
);


ALTER TABLE public.pbx_disa OWNER TO contacte;

--
-- Name: pbx_disa_numeros_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_disa_numeros_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_disa_numeros_id_seq OWNER TO contacte;

--
-- Name: pbx_disa_numeros; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_disa_numeros (
    id integer DEFAULT nextval('pbx_disa_numeros_id_seq'::regclass) NOT NULL,
    id_disa integer,
    numeros character varying(100)
);


ALTER TABLE public.pbx_disa_numeros OWNER TO contacte;

--
-- Name: pbx_empresa; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_empresa (
    id integer NOT NULL,
    nome character varying(50) NOT NULL,
    razao_social character varying(100) NOT NULL,
    endereco_site character varying(300) NOT NULL,
    tag integer DEFAULT 0 NOT NULL,
    origem character varying(30)
);


ALTER TABLE public.pbx_empresa OWNER TO contacte;

--
-- Name: pbx_empresa_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_empresa_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_empresa_id_seq OWNER TO contacte;

--
-- Name: pbx_estrategia_distribuicao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_estrategia_distribuicao (
    est_id character varying(20) NOT NULL,
    est_descricao character varying(120),
    iduser integer,
    datareg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_estrategia_distribuicao OWNER TO contacte;

--
-- Name: pbx_eventos_agentes_wpp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_eventos_agentes_wpp (
    id integer NOT NULL,
    matricula character varying NOT NULL,
    ramal character varying NOT NULL,
    entrada_pausa timestamp(0) without time zone,
    saida_pausa timestamp(0) without time zone,
    id_motivo_pausa integer,
    login timestamp(0) without time zone,
    logoff timestamp(0) without time zone,
    duracao time(0) without time zone,
    id_dac integer NOT NULL,
    relaciona_eventos integer DEFAULT 0 NOT NULL,
    flag integer DEFAULT 10,
    pausa_produtiva integer DEFAULT 0 NOT NULL,
    pausa_produtiva_obs character varying(255),
    reg_proc character varying(1024),
    data_operacao date DEFAULT (now())::date NOT NULL
);


ALTER TABLE public.pbx_eventos_agentes_wpp OWNER TO contacte;

--
-- Name: pbx_eventos_agentes_wpp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_eventos_agentes_wpp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_agentes_wpp_id_seq OWNER TO contacte;

--
-- Name: pbx_eventos_agentes_wpp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_eventos_agentes_wpp_id_seq OWNED BY pbx_eventos_agentes_wpp.id;


--
-- Name: pbx_eventos_dac_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_eventos_dac_id_seq
    START WITH 1
    INCREMENT BY 1
    MAXVALUE 2147483647
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_dac_id_seq OWNER TO postgres;

--
-- Name: pbx_eventos_dac_id_seq1; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_eventos_dac_id_seq1
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_dac_id_seq1 OWNER TO postgres;

--
-- Name: pbx_eventos_dacs_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_eventos_dacs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_dacs_id_seq OWNER TO contacte;

--
-- Name: pbx_eventos_dacs; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_eventos_dacs (
    id integer DEFAULT nextval('pbx_eventos_dacs_id_seq'::regclass) NOT NULL,
    uid1 character varying(50) NOT NULL,
    uid2 character varying(50),
    fila character varying(50),
    agente character varying(50),
    evento character varying(80),
    param1 character varying(50),
    param2 character varying(50),
    param3 character varying(50),
    param4 character varying(50)
);


ALTER TABLE public.pbx_eventos_dacs OWNER TO contacte;

--
-- Name: pbx_eventos_dacs_wpp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_eventos_dacs_wpp (
    id integer NOT NULL,
    uid1 character varying(50) NOT NULL,
    uid2 character varying(50),
    fila character varying(50),
    agente character varying(50),
    evento character varying(80),
    param1 character varying(50),
    param2 character varying(50),
    param3 character varying(50),
    param4 character varying(50)
);


ALTER TABLE public.pbx_eventos_dacs_wpp OWNER TO contacte;

--
-- Name: pbx_eventos_dacs_wpp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_eventos_dacs_wpp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_dacs_wpp_id_seq OWNER TO contacte;

--
-- Name: pbx_eventos_dacs_wpp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_eventos_dacs_wpp_id_seq OWNED BY pbx_eventos_dacs_wpp.id;


--
-- Name: pbx_eventos_transbordo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_eventos_transbordo (
    trbd_id bigint NOT NULL,
    fila character varying(64) NOT NULL,
    trbd_origem_destino_tipo character varying(64),
    trbd_origem_destino character varying(64),
    uniqueid character varying(32) NOT NULL,
    trbd_tipo character(1) NOT NULL,
    trbd_aplicacao character varying(64),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    trbd_controle integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_eventos_transbordo OWNER TO contacte;

--
-- Name: pbx_eventos_transbordo_trbd_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_eventos_transbordo_trbd_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_transbordo_trbd_id_seq OWNER TO contacte;

--
-- Name: pbx_eventos_transbordo_trbd_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_eventos_transbordo_trbd_id_seq OWNED BY pbx_eventos_transbordo.trbd_id;


--
-- Name: pbx_eventos_usuarios_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_eventos_usuarios_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_usuarios_id_seq OWNER TO postgres;

--
-- Name: pbx_eventos_usuarios_relaciona_eventos_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_eventos_usuarios_relaciona_eventos_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_eventos_usuarios_relaciona_eventos_seq OWNER TO postgres;

--
-- Name: pbx_facilidades; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_facilidades (
    app_hora character varying(20),
    app_echo character varying(20),
    app_troca_senha_ramal character varying(20),
    app_nao_pertube_ativa character varying(20),
    app_nao_pertube_desativa character varying(20),
    app_siga_me_interno_ativa character varying(20),
    app_siga_me_interno_desativa character varying(20),
    app_siga_me_externo_ativa character varying(20),
    app_siga_me_externo_desativa character varying(20),
    app_siga_me_ocupado_ativa character varying(20),
    app_siga_me_ocupado_desativa character varying(20),
    app_siga_me_nresponde_ativa character varying(20),
    app_siga_me_nresponde_desativa character varying(20),
    app_rechamada_ativa character varying(20),
    app_rechamada_desativa character varying(20),
    app_cadeado_ativa character varying(20),
    app_cadeado_desativa character varying(20),
    app_chamada_espera_ativa character varying(20),
    app_chamada_espera_desativa character varying(20),
    app_identifica_vm character varying(20),
    app_acessa_vm character varying(20),
    app_agenda_ramal_adiciona character varying(20),
    app_agenda_ramal_exclui character varying(20),
    app_agenda_publica_adiciona character varying(20),
    app_agenda_publica_exclui character varying(20),
    app_ultimo_recebido character varying(20),
    app_monitoramento character varying(20),
    app_identifica_ramal character varying(20),
    app_discagem_agenda_ramal character varying(20),
    app_discagem_agenda_publica character varying(20),
    troca_senha character varying(20),
    captura_chamada character varying(20),
    app_intercalar character varying(20),
    app_ranger_ramais character varying(50),
    ausencia_grupo_ativa character varying(20) DEFAULT '*40'::character varying NOT NULL,
    ausencia_grupo_desativa character varying(20) DEFAULT '*41'::character varying NOT NULL,
    conferencia_dinamica character varying(20) DEFAULT '*99'::character varying NOT NULL
);


ALTER TABLE public.pbx_facilidades OWNER TO contacte;

--
-- Name: pbx_features_application_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_features_application_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_features_application_id_seq OWNER TO contacte;

--
-- Name: pbx_features_application; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_features_application (
    id integer DEFAULT nextval('pbx_features_application_id_seq'::regclass) NOT NULL,
    seq integer,
    comando character varying(100)
);


ALTER TABLE public.pbx_features_application OWNER TO contacte;

--
-- Name: pbx_features_featuremap; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_features_featuremap (
    blindxfer character varying(10),
    disconnect character varying(10),
    automon character varying(10),
    atxfer character varying(10),
    parkcall character varying(10)
);


ALTER TABLE public.pbx_features_featuremap OWNER TO contacte;

--
-- Name: pbx_features_general; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_features_general (
    parkext integer,
    parkingtime integer,
    courtesytone character varying(100),
    parkedplay character varying(100),
    adsipark character varying(3),
    findslot character varying(100),
    parkedmusicclass character varying(100),
    transferdigittimeout integer,
    xfersound character varying(100),
    xferfailsound character varying(100),
    pickupexten character varying(10),
    featuredigittimeout integer,
    atxfernoanswertimeout integer,
    parkpos character varying(100),
    context character varying(100)
);


ALTER TABLE public.pbx_features_general OWNER TO contacte;

--
-- Name: pbx_fila_audios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_fila_audios (
    id integer NOT NULL,
    gp_id integer NOT NULL
);


ALTER TABLE public.pbx_fila_audios OWNER TO contacte;

--
-- Name: pbx_fila_grupos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_fila_grupos (
    id integer NOT NULL,
    gp_id integer NOT NULL
);


ALTER TABLE public.pbx_fila_grupos OWNER TO contacte;

--
-- Name: pbx_fornecedor_permissao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_fornecedor_permissao (
    id_cfr_permissao integer NOT NULL,
    cfr_id integer NOT NULL,
    matricula_permissao character varying(100) NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_fornecedor_permissao OWNER TO contacte;

--
-- Name: pbx_fornecedor_permissao_id_cfr_permissao_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_fornecedor_permissao_id_cfr_permissao_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_fornecedor_permissao_id_cfr_permissao_seq OWNER TO contacte;

--
-- Name: pbx_fornecedor_permissao_id_cfr_permissao_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_fornecedor_permissao_id_cfr_permissao_seq OWNED BY pbx_fornecedor_permissao.id_cfr_permissao;


--
-- Name: pbx_funcoes_fun_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_funcoes_fun_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_funcoes_fun_id_seq OWNER TO postgres;

--
-- Name: pbx_funcoes; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_funcoes (
    fun_id integer DEFAULT nextval('pbx_funcoes_fun_id_seq'::regclass) NOT NULL,
    fun_nome character varying(50) NOT NULL,
    fun_menu integer DEFAULT 0 NOT NULL,
    fun_menu_text character varying(255),
    fun_menu_url character varying(1024),
    fun_menu_img character varying(1024),
    fun_id_pai integer,
    fun_status integer DEFAULT 1 NOT NULL,
    fun_public integer DEFAULT 0 NOT NULL,
    ord integer,
    id_prog integer,
    fun_interna integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_funcoes OWNER TO postgres;

--
-- Name: pbx_funcoes_internas; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_funcoes_internas (
    id_prog integer NOT NULL,
    arquivo character varying(1024) NOT NULL,
    id_prog_pai integer,
    status integer DEFAULT 0 NOT NULL,
    exit integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_funcoes_internas OWNER TO contacte;

--
-- Name: pbx_funcoes_menu_pbx; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_funcoes_menu_pbx AS
    SELECT a.fun_id, a.fun_nome, a.fun_menu, a.fun_menu_text, a.fun_menu_url, a.fun_menu_img, a.fun_id_pai, a.fun_status, a.fun_public FROM (SELECT b.fun_id, b.fun_nome, b.fun_menu, b.fun_menu_text, b.fun_menu_url, b.fun_menu_img, b.fun_id_pai, b.fun_status, b.fun_public FROM pbx_funcoes a, pbx_funcoes b WHERE (b.fun_id_pai = a.fun_id)) a, pbx_funcoes b WHERE ((a.fun_id_pai = b.fun_id) AND (b.fun_id_pai = (SELECT pbx_funcoes.fun_id FROM pbx_funcoes WHERE (upper((pbx_funcoes.fun_nome)::text) = 'MNPBX'::text)))) UNION ALL (SELECT DISTINCT b.fun_id, b.fun_nome, b.fun_menu, b.fun_menu_text, b.fun_menu_url, b.fun_menu_img, b.fun_id_pai, b.fun_status, b.fun_public FROM (SELECT b.fun_id, b.fun_nome, b.fun_menu, b.fun_menu_text, b.fun_menu_url, b.fun_menu_img, b.fun_id_pai, b.fun_status, b.fun_public FROM pbx_funcoes a, pbx_funcoes b WHERE (b.fun_id_pai = a.fun_id)) a, pbx_funcoes b WHERE ((a.fun_id_pai = b.fun_id) AND (b.fun_id_pai = (SELECT pbx_funcoes.fun_id FROM pbx_funcoes WHERE (upper((pbx_funcoes.fun_nome)::text) = 'MNPBX'::text)))) ORDER BY b.fun_id, b.fun_nome, b.fun_menu, b.fun_menu_text, b.fun_menu_url, b.fun_menu_img, b.fun_id_pai, b.fun_status, b.fun_public);


ALTER TABLE public.pbx_funcoes_menu_pbx OWNER TO contacte;

--
-- Name: pbx_grupo_gp_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_grupo_gp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_grupo_gp_id_seq OWNER TO postgres;

--
-- Name: pbx_grupo; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_grupo (
    gp_id integer DEFAULT nextval('pbx_grupo_gp_id_seq'::regclass) NOT NULL,
    gp_nome character varying(50) NOT NULL,
    gp_status integer DEFAULT 1 NOT NULL,
    user_id integer DEFAULT 0 NOT NULL,
    gp_user integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_grupo OWNER TO postgres;

--
-- Name: pbx_grupo_audio_ramal; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupo_audio_ramal (
    nome character varying(32) NOT NULL,
    gp_id integer NOT NULL
);


ALTER TABLE public.pbx_grupo_audio_ramal OWNER TO contacte;

--
-- Name: pbx_grupo_campanha_contato_status; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupo_campanha_contato_status (
    ctst_id integer NOT NULL,
    gp_id integer NOT NULL
);


ALTER TABLE public.pbx_grupo_campanha_contato_status OWNER TO contacte;

--
-- Name: pbx_grupo_funcoes; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_grupo_funcoes (
    gp_id integer NOT NULL,
    fun_id integer NOT NULL
);


ALTER TABLE public.pbx_grupo_funcoes OWNER TO postgres;

--
-- Name: pbx_grupo_revendas; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupo_revendas (
    gp_id integer NOT NULL,
    emp_id integer NOT NULL
);


ALTER TABLE public.pbx_grupo_revendas OWNER TO contacte;

--
-- Name: pbx_grupo_ura_ramal; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupo_ura_ramal (
    id integer NOT NULL,
    id_ura integer NOT NULL,
    id_ramal integer NOT NULL,
    data_reg timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_grupo_ura_ramal OWNER TO contacte;

--
-- Name: pbx_grupo_ura_ramal_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_grupo_ura_ramal_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_grupo_ura_ramal_id_seq OWNER TO contacte;

--
-- Name: pbx_grupo_ura_ramal_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_grupo_ura_ramal_id_seq OWNED BY pbx_grupo_ura_ramal.id;


--
-- Name: pbx_grupo_usuario; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_grupo_usuario (
    user_id integer NOT NULL,
    gp_id integer NOT NULL
);


ALTER TABLE public.pbx_grupo_usuario OWNER TO postgres;

--
-- Name: pbx_grupos_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_grupos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_grupos_id_seq OWNER TO contacte;

--
-- Name: pbx_grupos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupos (
    id integer DEFAULT nextval('pbx_grupos_id_seq'::regclass) NOT NULL,
    numero character varying(100),
    descricao character varying(100),
    tipo character varying(10),
    musica_espera character varying(1),
    anuncio character varying(100),
    tempo_ring integer,
    opcao character varying(50),
    acao character varying(100),
    musicclass character varying(100),
    tentar_novamente character varying(1)
);


ALTER TABLE public.pbx_grupos OWNER TO contacte;

--
-- Name: pbx_grupos_atendimento_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_grupos_atendimento_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_grupos_atendimento_id_seq OWNER TO contacte;

--
-- Name: pbx_grupos_atendimento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupos_atendimento (
    id integer DEFAULT nextval('pbx_grupos_atendimento_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    status boolean
);


ALTER TABLE public.pbx_grupos_atendimento OWNER TO contacte;

--
-- Name: pbx_grupos_atendimento_ramais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupos_atendimento_ramais (
    id_grupo integer NOT NULL,
    ramal character varying(100)
);


ALTER TABLE public.pbx_grupos_atendimento_ramais OWNER TO contacte;

--
-- Name: pbx_grupos_numeros; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_grupos_numeros (
    id_grupo integer,
    ramal character varying(10)
);


ALTER TABLE public.pbx_grupos_numeros OWNER TO contacte;

--
-- Name: pbx_hora_dia; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_hora_dia (
    hora_ini time without time zone NOT NULL,
    hora_fim time without time zone NOT NULL,
    periodo integer NOT NULL
);


ALTER TABLE public.pbx_hora_dia OWNER TO postgres;

--
-- Name: pbx_hora_meta; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_hora_meta (
    hora_ini time without time zone NOT NULL,
    hora_fim time without time zone NOT NULL,
    tempo integer NOT NULL
);


ALTER TABLE public.pbx_hora_meta OWNER TO postgres;

SET default_with_oids = true;

--
-- Name: pbx_horarios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_horarios (
    id integer NOT NULL,
    nome character varying(100),
    discar character varying(25),
    opcao_ok character varying(100),
    acao_ok character varying(100),
    opcao_nao character varying(100),
    acao_nao character varying(100),
    status integer DEFAULT 0
);


ALTER TABLE public.pbx_horarios OWNER TO contacte;

--
-- Name: pbx_horarios_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_horarios_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_horarios_id_seq OWNER TO contacte;

--
-- Name: pbx_horarios_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_horarios_id_seq OWNED BY pbx_horarios.id;


SET default_with_oids = false;

--
-- Name: pbx_horarios_itens; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_horarios_itens (
    id integer NOT NULL,
    id_horario integer,
    horario_inicio character varying(5) NOT NULL,
    horario_fim character varying(5) NOT NULL,
    todos_dias_semana integer DEFAULT 1,
    semana character varying(20),
    semana_fim character varying(20),
    todos_dias_mes integer DEFAULT 1 NOT NULL,
    dias_mes integer,
    dias_mes_fim integer,
    todos_mes integer DEFAULT 1 NOT NULL,
    mes character varying(20),
    mes_fim character varying(20),
    opcao character varying(100),
    acao character varying(100),
    feriado character(1) DEFAULT 'I'::bpchar NOT NULL
);


ALTER TABLE public.pbx_horarios_itens OWNER TO contacte;

--
-- Name: pbx_horarios_itens_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_horarios_itens_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_horarios_itens_id_seq OWNER TO contacte;

--
-- Name: pbx_horarios_itens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_horarios_itens_id_seq OWNED BY pbx_horarios_itens.id;


--
-- Name: pbx_hosts_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_hosts_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_hosts_id_seq OWNER TO postgres;

--
-- Name: pbx_hosts_id_seq1; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_hosts_id_seq1
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_hosts_id_seq1 OWNER TO contacte;

--
-- Name: pbx_iax_general; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_iax_general (
    bindport character varying(10),
    bindaddr character varying(100),
    autokill character varying(3),
    amaflags character varying(100),
    accountcode character varying(100),
    trunkfreq integer,
    trunktimestamps character varying(3),
    minregexpire integer,
    maxregexpire integer,
    authdebug character varying(3),
    tos character varying(100)
);


ALTER TABLE public.pbx_iax_general OWNER TO postgres;

--
-- Name: pbx_iax_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_iax_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_iax_id_seq OWNER TO contacte;

--
-- Name: pbx_iax_pbx_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_iax_pbx_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_iax_pbx_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_iax_pbx; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_iax_pbx (
    id integer DEFAULT nextval('pbx_iax_pbx_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    type character varying(100),
    host character varying(100),
    callgroup character varying(100),
    pickupgroup character varying(100),
    secret character varying(100),
    context character varying(100),
    disallow character varying(100),
    allow character varying(100),
    deny character varying(100),
    permit character varying(100),
    requirecalltoken character varying(4),
    inkeys character varying(100),
    outkeys character varying(100),
    espera character varying(1),
    sigame_interno character varying(20),
    sigame_externo character varying(20),
    sigame_naoatende character varying(20),
    sigame_ocupado character varying(20),
    gravacao_chamada character varying(1),
    musica_espera character varying(100),
    nao_pertube character varying(1),
    cadeado character varying(1),
    senha_voice character varying(10),
    dispositivo character varying(250),
    gravacao_saida character varying(1),
    mailbox character varying(100),
    senha_facilidade character varying(100),
    identificador character varying(100),
    identificador2 character varying(100),
    conta_senha character varying(1) DEFAULT 'V'::character varying NOT NULL,
    ramalsecretaria character varying(20),
    saldo_prepago numeric(12,4) DEFAULT 0,
    habilita_prepago integer DEFAULT 0 NOT NULL,
    ring_time character varying(100),
    timeout character varying(16)
);


ALTER TABLE public.pbx_iax_pbx OWNER TO contacte;

--
-- Name: pbx_indisponivel_ind_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_indisponivel_ind_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_indisponivel_ind_id_seq OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_indisponivel; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_indisponivel (
    id_dac integer NOT NULL,
    ind_data date NOT NULL,
    ind_inicio time without time zone NOT NULL,
    ind_fim time without time zone NOT NULL,
    id_usuario integer,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    status integer DEFAULT 1 NOT NULL,
    ind_id integer DEFAULT nextval('pbx_indisponivel_ind_id_seq'::regclass) NOT NULL,
    ind_file character varying(1024),
    ind_feriado integer DEFAULT 0 NOT NULL,
    ind_descricao character varying(80)
);


ALTER TABLE public.pbx_indisponivel OWNER TO contacte;

--
-- Name: pbx_indisponivel_fila; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_indisponivel_fila (
    id_dac integer NOT NULL,
    matricula character varying(4) NOT NULL,
    idf_entrada timestamp without time zone NOT NULL,
    idf_saida timestamp without time zone,
    id_login integer
);


ALTER TABLE public.pbx_indisponivel_fila OWNER TO contacte;

--
-- Name: pbx_integracao_agente_ativo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_agente_ativo (
    id_itgc integer NOT NULL,
    nome_cliente character varying(128),
    telefone character varying(11),
    ramal character varying(4),
    cpf_cnpj character varying(14)
);


ALTER TABLE public.pbx_integracao_agente_ativo OWNER TO contacte;

--
-- Name: pbx_integracao_agente_ativo_id_itgc_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_integracao_agente_ativo_id_itgc_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_integracao_agente_ativo_id_itgc_seq OWNER TO contacte;

--
-- Name: pbx_integracao_agente_ativo_id_itgc_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_integracao_agente_ativo_id_itgc_seq OWNED BY pbx_integracao_agente_ativo.id_itgc;


--
-- Name: pbx_integracao_configuracao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_configuracao (
    itgc_id integer NOT NULL,
    itgt_id integer NOT NULL,
    itgp_id integer NOT NULL,
    itgc_nome character varying(64) NOT NULL,
    itgc_host character varying(128) NOT NULL,
    itgc_database character varying(128) NOT NULL,
    itgc_user character varying(32),
    itgc_password character varying(128),
    itgc_timeout integer DEFAULT 10 NOT NULL,
    opcao character varying(100),
    acao character varying(100),
    itgc_status integer DEFAULT 0 NOT NULL,
    itgc_port character varying(20)
);


ALTER TABLE public.pbx_integracao_configuracao OWNER TO contacte;

--
-- Name: pbx_integracao_configuracao_itgc_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_integracao_configuracao_itgc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_integracao_configuracao_itgc_id_seq OWNER TO contacte;

--
-- Name: pbx_integracao_configuracao_itgc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_integracao_configuracao_itgc_id_seq OWNED BY pbx_integracao_configuracao.itgc_id;


--
-- Name: pbx_integracao_dados; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_dados (
    int_id character varying(21) NOT NULL,
    int_dados character varying(254) NOT NULL,
    int_data timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_integracao_dados OWNER TO contacte;

--
-- Name: pbx_integracao_metodo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_metodo (
    itgm_id integer NOT NULL,
    itgc_id integer NOT NULL,
    itgm_nome character varying(64) NOT NULL,
    itgm_tipo integer DEFAULT 1,
    itgm_comando text NOT NULL,
    itgm_retorno integer DEFAULT 0,
    itgm_status integer DEFAULT 0,
    opcao character varying(100),
    evento integer,
    stored_params character varying(2048),
    itgm_id_pai integer
);


ALTER TABLE public.pbx_integracao_metodo OWNER TO contacte;

--
-- Name: pbx_integracao_metodo_itgm_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_integracao_metodo_itgm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_integracao_metodo_itgm_id_seq OWNER TO contacte;

--
-- Name: pbx_integracao_metodo_itgm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_integracao_metodo_itgm_id_seq OWNED BY pbx_integracao_metodo.itgm_id;


--
-- Name: pbx_integracao_parametro; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_parametro (
    itgp_id character varying(64) NOT NULL,
    itgm_id integer NOT NULL,
    itgp_nome character varying(64) NOT NULL,
    itgp_tipo character varying(64),
    itgp_tamanho integer,
    itgp_direcao integer,
    itgp_default character varying(64)
);


ALTER TABLE public.pbx_integracao_parametro OWNER TO contacte;

--
-- Name: pbx_integracao_protocolo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_protocolo (
    itgt_id integer NOT NULL,
    itgp_id integer NOT NULL,
    itgp_descricao character varying(64) NOT NULL,
    itgp_port character varying(64),
    itgp_status integer,
    itgp_prefix character varying(10) DEFAULT 'pgsql'::character varying NOT NULL
);


ALTER TABLE public.pbx_integracao_protocolo OWNER TO contacte;

--
-- Name: pbx_integracao_reg; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_reg (
    reg_id bigint NOT NULL,
    reg_data date DEFAULT (now())::date NOT NULL,
    reg_id_metodo integer,
    reg_uniqueid character varying(32) NOT NULL,
    reg_uniqueid_old character varying(32) NOT NULL,
    reg_fone character varying(32),
    reg_retorno character varying(120),
    reg_inicio timestamp without time zone,
    reg_fim timestamp without time zone,
    reg_msg character varying(1024),
    reg_status_exec integer DEFAULT 0 NOT NULL,
    reg_status integer DEFAULT 0 NOT NULL,
    datareg timestamp without time zone DEFAULT now() NOT NULL,
    reg_msg_evt character varying(1024),
    reg_data_evt timestamp without time zone,
    retorno_cliente character varying(255),
    reg_encerrada integer DEFAULT 0 NOT NULL,
    reg_tronco character varying(32),
    reg_ramal character varying(32),
    reg_ura character varying(32)
);


ALTER TABLE public.pbx_integracao_reg OWNER TO contacte;

--
-- Name: pbx_integracao_reg_reg_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_integracao_reg_reg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_integracao_reg_reg_id_seq OWNER TO contacte;

--
-- Name: pbx_integracao_reg_reg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_integracao_reg_reg_id_seq OWNED BY pbx_integracao_reg.reg_id;


--
-- Name: pbx_integracao_tipo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_integracao_tipo (
    itgt_id integer NOT NULL,
    itgt_descricao character varying(64) NOT NULL,
    itgt_status integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_integracao_tipo OWNER TO contacte;

--
-- Name: pbx_integracao_tipo_itgt_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_integracao_tipo_itgt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_integracao_tipo_itgt_id_seq OWNER TO contacte;

--
-- Name: pbx_integracao_tipo_itgt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_integracao_tipo_itgt_id_seq OWNED BY pbx_integracao_tipo.itgt_id;


--
-- Name: pbx_khomp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_khomp (
    id integer NOT NULL,
    senha integer,
    dispositivo character varying(250),
    voicemail character varying(20),
    senha_v character varying(20),
    usuario_v character varying(20),
    contexto character varying(20),
    grupo character varying(20),
    imediate character varying(20),
    accountcode character varying(100),
    capturar character varying(100),
    espera character varying(1),
    sigame_interno character varying(20),
    sigame_externo character varying(20),
    sigame_naoatende character varying(20),
    sigame_ocupado character varying(20),
    gravacao_chamada character varying(1),
    musica_espera character varying(100),
    nao_pertube character varying(1),
    cadeado character varying(1),
    gravacao_saida character varying(1),
    senha_facilidade character varying(100),
    identificador character varying(100),
    numero character varying(10),
    identificador2 character varying(100),
    conta_senha character varying(1) DEFAULT 'V'::character varying NOT NULL,
    ramalsecretaria character varying(20),
    saldo_prepago numeric(12,4) DEFAULT 0,
    habilita_prepago integer DEFAULT 0 NOT NULL,
    numero_serie character varying(11),
    numero_khomp character varying(11),
    volume_input character varying(11),
    volume_output character varying(11),
    ring_time character varying(100),
    timeout character varying(16)
);


ALTER TABLE public.pbx_khomp OWNER TO contacte;

--
-- Name: pbx_khomp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_khomp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_khomp_id_seq OWNER TO contacte;

--
-- Name: pbx_khomp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_khomp_id_seq OWNED BY pbx_khomp.id;


--
-- Name: pbx_kingdialer_bloqueios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_kingdialer_bloqueios (
    id_bloq integer NOT NULL,
    id_camp_bloq integer NOT NULL,
    nome_camp_bloq character varying(250) NOT NULL,
    numero_bloq character varying(20) NOT NULL,
    tipo_bloq integer NOT NULL,
    data_bloq timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_kingdialer_bloqueios OWNER TO contacte;

--
-- Name: pbx_kingdialer_bloqueios_id_bloq_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_kingdialer_bloqueios_id_bloq_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_kingdialer_bloqueios_id_bloq_seq OWNER TO contacte;

--
-- Name: pbx_kingdialer_bloqueios_id_bloq_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_kingdialer_bloqueios_id_bloq_seq OWNED BY pbx_kingdialer_bloqueios.id_bloq;


--
-- Name: pbx_kingdialer_campanha; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_kingdialer_campanha (
    id_camp_king integer NOT NULL,
    king_camp_login character varying(15) NOT NULL,
    king_camp_horaini character varying(10) NOT NULL,
    king_camp_horafim character varying(10) NOT NULL,
    king_camp_ramal character varying(20) NOT NULL,
    king_camp_fluxo integer NOT NULL,
    king_camp_pausa integer NOT NULL,
    king_camp_numrediscagem integer NOT NULL,
    king_camp_maxcall integer NOT NULL,
    king_camp_ringtime integer NOT NULL,
    king_camp_intervalo integer NOT NULL,
    king_camp_amd integer NOT NULL,
    king_camp_nds integer NOT NULL,
    king_camp_priomovel integer NOT NULL,
    king_camp_maxcallagent integer NOT NULL
);


ALTER TABLE public.pbx_kingdialer_campanha OWNER TO contacte;

--
-- Name: pbx_kingdialer_campanha_id_camp_king_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_kingdialer_campanha_id_camp_king_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_kingdialer_campanha_id_camp_king_seq OWNER TO contacte;

--
-- Name: pbx_kingdialer_campanha_id_camp_king_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_kingdialer_campanha_id_camp_king_seq OWNED BY pbx_kingdialer_campanha.id_camp_king;


--
-- Name: pbx_kingdialer_config; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_kingdialer_config (
    id_king integer NOT NULL,
    king_host character varying(15) NOT NULL,
    king_port character varying(5) NOT NULL,
    king_base character varying(20) NOT NULL,
    king_user character varying(20) NOT NULL,
    king_password character varying(20) NOT NULL
);


ALTER TABLE public.pbx_kingdialer_config OWNER TO contacte;

--
-- Name: pbx_kingdialer_config_id_king_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_kingdialer_config_id_king_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_kingdialer_config_id_king_seq OWNER TO contacte;

--
-- Name: pbx_kingdialer_config_id_king_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_kingdialer_config_id_king_seq OWNED BY pbx_kingdialer_config.id_king;


--
-- Name: pbx_ligueme_gratis; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_ligueme_gratis (
    id_ligueme_gratis integer NOT NULL,
    uid_contato integer,
    nome_contato character varying(50),
    telefone_contato character varying(20),
    result_contato character varying(100),
    mensagem_contato character varying(255),
    sipid_contato character varying(100),
    data_reg timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_ligueme_gratis OWNER TO contacte;

--
-- Name: pbx_ligueme_gratis_id_ligueme_gratis_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_ligueme_gratis_id_ligueme_gratis_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_ligueme_gratis_id_ligueme_gratis_seq OWNER TO contacte;

--
-- Name: pbx_ligueme_gratis_id_ligueme_gratis_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_ligueme_gratis_id_ligueme_gratis_seq OWNED BY pbx_ligueme_gratis.id_ligueme_gratis;


--
-- Name: pbx_links_linkid_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_links_linkid_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_links_linkid_seq OWNER TO contacte;

--
-- Name: pbx_links; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_links (
    linkid bigint DEFAULT nextval('pbx_links_linkid_seq'::regclass) NOT NULL,
    uniqueid1 character varying(32),
    uniqueid2 character varying(32),
    link character varying(80)
);


ALTER TABLE public.pbx_links OWNER TO contacte;

--
-- Name: pbx_ura_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_ura_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_ura_id_seq OWNER TO contacte;

--
-- Name: pbx_ura; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_ura (
    id integer DEFAULT nextval('pbx_ura_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    permite_ligacao character(1),
    tempo_espera integer NOT NULL,
    som_ura character varying(100),
    teste character varying(7),
    opcao character varying(30),
    acao character varying(100),
    timeout_digito integer DEFAULT 1 NOT NULL,
    ura_desc character varying(4096)
);


ALTER TABLE public.pbx_ura OWNER TO contacte;

--
-- Name: pbx_lista_arquivo_som; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_lista_arquivo_som AS
    SELECT a.tipo, a.arq_som FROM ((SELECT 'ura' AS tipo, pbx_ura.som_ura AS arq_som FROM pbx_ura UNION SELECT 'anuncio' AS tipo, pbx_anuncios.musica AS arq_som FROM pbx_anuncios) UNION SELECT 'conferencia' AS tipo, pbx_conferencia.anuncio AS arq_som FROM pbx_conferencia) a WHERE (btrim((a.arq_som)::text) <> ''::text);


ALTER TABLE public.pbx_lista_arquivo_som OWNER TO contacte;

--
-- Name: pbx_lista_discador; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_lista_discador (
    ld_id integer NOT NULL,
    ld_data date NOT NULL,
    ld_original character varying(64),
    ld_nome character varying(64),
    ld_path character varying(128),
    ld_num_linhas integer,
    ld_md5 character varying(32),
    ld_process integer DEFAULT 0 NOT NULL,
    ld_line_process integer DEFAULT 0,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    ld_id_campanha_king integer
);


ALTER TABLE public.pbx_lista_discador OWNER TO simplesip;

--
-- Name: pbx_lista_discador_ld_id_seq; Type: SEQUENCE; Schema: public; Owner: simplesip
--

CREATE SEQUENCE pbx_lista_discador_ld_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_lista_discador_ld_id_seq OWNER TO simplesip;

--
-- Name: pbx_lista_discador_ld_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: simplesip
--

ALTER SEQUENCE pbx_lista_discador_ld_id_seq OWNED BY pbx_lista_discador.ld_id;


--
-- Name: pbx_lista_negra_palavras; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_lista_negra_palavras (
    id integer NOT NULL,
    palavra character varying NOT NULL,
    date_create timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_lista_negra_palavras OWNER TO contacte;

--
-- Name: pbx_lista_negra_palavras_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_lista_negra_palavras_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_lista_negra_palavras_id_seq OWNER TO contacte;

--
-- Name: pbx_lista_negra_palavras_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_lista_negra_palavras_id_seq OWNED BY pbx_lista_negra_palavras.id;


--
-- Name: pbx_listanegra_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_listanegra_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_listanegra_id_seq OWNER TO contacte;

--
-- Name: pbx_listanegra; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_listanegra (
    id integer DEFAULT nextval('pbx_listanegra_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    numero character varying(50),
    acao character varying(100),
    entrada integer DEFAULT 0,
    saida integer DEFAULT 0,
    opcao character varying(100),
    id_pai integer,
    flag character varying(128)
);


ALTER TABLE public.pbx_listanegra OWNER TO contacte;

--
-- Name: pbx_listanegra_rota; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_listanegra_rota (
    id_rota integer NOT NULL,
    id_lista integer NOT NULL,
    tipo_rota character(1) NOT NULL
);


ALTER TABLE public.pbx_listanegra_rota OWNER TO contacte;

--
-- Name: pbx_rotas_entrada_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_rotas_entrada_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_rotas_entrada_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_rotas_entrada; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_rotas_entrada (
    id integer DEFAULT nextval('pbx_rotas_entrada_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    modelo_entrada character varying(100),
    ativar_ddr character varying(1),
    musica_espera character varying(1),
    anuncio character varying(100),
    opcao character varying(100),
    acao character varying(100),
    modelos character varying(2048),
    identificador character varying(100),
    limite_ligacao character varying(32),
    serv_id character varying(64),
    limite_ligacao_pos_opcao character varying(150),
    limite_ligacao_pos_acao character varying(150)
);


ALTER TABLE public.pbx_rotas_entrada OWNER TO contacte;

--
-- Name: pbx_localiza_opcoes; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_localiza_opcoes AS
    ((((((((((SELECT pbx_horarios_itens.id, 'pbx_horarios_itens' AS tabela, pbx_horarios_itens.opcao, pbx_horarios_itens.acao FROM pbx_horarios_itens UNION ALL SELECT pbx_listanegra.id, 'pbx_listanegra' AS tabela, pbx_listanegra.opcao, pbx_listanegra.acao FROM pbx_listanegra) UNION ALL SELECT pbx_anuncios.id, 'pbx_anuncios' AS tabela, pbx_anuncios.opcao, pbx_anuncios.acao FROM pbx_anuncios) UNION ALL SELECT pbx_queues_grupos.id, 'pbx_queues_grupos' AS tabela, pbx_queues_grupos.opcao, pbx_queues_grupos.acao FROM pbx_queues_grupos) UNION ALL SELECT pbx_ura.id, 'pbx_ura' AS tabela, pbx_ura.opcao, pbx_ura.acao FROM pbx_ura) UNION ALL SELECT pbx_contextos_opcoes.id, 'pbx_contextos_opcoes' AS tabela, pbx_contextos_opcoes.opcao, pbx_contextos_opcoes.acao FROM pbx_contextos_opcoes) UNION ALL SELECT pbx_disa.id, 'pbx_disa' AS tabela, pbx_disa.opcao, pbx_disa.acao FROM pbx_disa) UNION ALL SELECT pbx_grupos.id, 'pbx_grupos' AS tabela, pbx_grupos.opcao, pbx_grupos.acao FROM pbx_grupos) UNION ALL SELECT pbx_rotas_entrada.id, 'pbx_rotas_entrada' AS tabela, pbx_rotas_entrada.opcao, pbx_rotas_entrada.acao FROM pbx_rotas_entrada) UNION ALL SELECT pbx_contextos_opcoes_tmp.id, 'pbx_contextos_opcoes_tmp' AS tabela, pbx_contextos_opcoes_tmp.opcao, pbx_contextos_opcoes_tmp.acao FROM pbx_contextos_opcoes_tmp) UNION ALL SELECT pbx_callback.id, 'pbx_callback' AS tabela, pbx_callback.opcao, pbx_callback.acao FROM pbx_callback) UNION ALL SELECT pbx_contextos.id, 'pbx_contextos' AS tabela, pbx_contextos.opcao, pbx_contextos.acao FROM pbx_contextos;


ALTER TABLE public.pbx_localiza_opcoes OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_log_forms; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_log_forms (
    log_id bigint NOT NULL,
    log_msg text,
    log_msg_sys text,
    log_type_sys character varying(30),
    log_file_sys character varying(1024),
    log_line_sys character varying(20),
    log_file_form character varying(1024),
    id_prog integer,
    log_usuario character varying(50),
    log_data timestamp without time zone,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_log_forms OWNER TO contacte;

--
-- Name: pbx_log_forms_log_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_log_forms_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_log_forms_log_id_seq OWNER TO contacte;

--
-- Name: pbx_log_forms_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_log_forms_log_id_seq OWNED BY pbx_log_forms.log_id;


SET default_with_oids = true;

--
-- Name: pbx_media_atendimento; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_media_atendimento (
    mat_data date NOT NULL,
    mat_semana integer,
    mat_dia_semana integer,
    mat_num_ca integer,
    mat_num_opr integer,
    mat_med_ca_opr integer,
    mat_dac integer NOT NULL
);


ALTER TABLE public.pbx_media_atendimento OWNER TO postgres;

--
-- Name: pbx_media_atendimento_dia; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_media_atendimento_dia (
    mat_dac integer NOT NULL,
    mat_data date NOT NULL,
    mat_periodo integer NOT NULL,
    mat_hora_ini time without time zone NOT NULL,
    mat_hora_fim time without time zone NOT NULL,
    mat_semana integer,
    mat_dia_semana integer,
    mat_num_ca integer,
    mat_num_opr integer,
    mat_med_ca_opr integer
);


ALTER TABLE public.pbx_media_atendimento_dia OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_message_wpp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_message_wpp (
    id integer NOT NULL,
    uniqueid character varying NOT NULL,
    src character varying NOT NULL,
    dst character varying NOT NULL,
    type character varying NOT NULL,
    content character varying NOT NULL,
    profile_name character varying NOT NULL,
    msg_date timestamp with time zone DEFAULT date_trunc('second'::text, now())
);


ALTER TABLE public.pbx_message_wpp OWNER TO contacte;

--
-- Name: pbx_message_wpp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_message_wpp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_message_wpp_id_seq OWNER TO contacte;

--
-- Name: pbx_message_wpp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_message_wpp_id_seq OWNED BY pbx_message_wpp.id;


--
-- Name: pbx_monitor_sequencia; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_monitor_sequencia
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_monitor_sequencia OWNER TO contacte;

--
-- Name: pbx_monitor_evento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_monitor_evento (
    id integer DEFAULT nextval('pbx_monitor_sequencia'::regclass) NOT NULL,
    evento character varying(100),
    privilege character varying(100),
    channel character varying(100),
    state character varying(100),
    callerid character varying(100),
    calleridname character varying(100),
    uniqueid character varying(100),
    context character varying(100),
    extension character varying(100),
    priority character varying(100),
    application character varying(100),
    appdata character varying(100),
    queue character varying(100),
    pposition character varying(100),
    count character varying(100),
    calleridnum character varying(100),
    "cause-txt" character varying(100),
    cause character varying(100),
    destinationcontext character varying(100),
    destination character varying(100),
    destinationchannel character varying(100),
    lastapplication character varying(100),
    lastdata character varying(100),
    starttime character varying(100),
    answertime character varying(100),
    endtime character varying(100),
    duration character varying(100),
    billableseconds character varying(100),
    disposition character varying(100),
    amaflags character varying(100),
    userfield character varying(100),
    "position" character varying(100),
    originalposition character varying(100),
    holdtime character varying(100),
    accountcode character varying(100),
    source character varying(100),
    srcuniqueid character varying(100),
    destuniqueid character varying(100),
    channel1 character varying(100),
    channel2 character varying(100),
    uniqueid1 character varying(100),
    uniqueid2 character varying(100),
    callerid1 character varying(100),
    callerid2 character varying(100),
    "cid-callingpres" character varying(100)
);


ALTER TABLE public.pbx_monitor_evento OWNER TO contacte;

--
-- Name: pbx_monitora_abdagi; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_monitora_abdagi (
    m_id bigint NOT NULL,
    uid character varying(64),
    dac character varying(64),
    numero character varying(64),
    matricula character varying(64),
    direcao character varying(64),
    evento character varying(64),
    atendidafila character varying(64),
    m_data date DEFAULT (now())::date NOT NULL,
    m_calldate timestamp without time zone DEFAULT now() NOT NULL,
    ramal character varying(32),
    motivo_pausa character varying(64),
    disponivel_atendimento character varying(16),
    chamada_classificado character varying(16),
    status_discador character varying(16),
    uid_pai character varying(32)
);


ALTER TABLE public.pbx_monitora_abdagi OWNER TO contacte;

--
-- Name: pbx_monitora_abdagi_m_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_monitora_abdagi_m_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_monitora_abdagi_m_id_seq OWNER TO contacte;

--
-- Name: pbx_monitora_abdagi_m_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_monitora_abdagi_m_id_seq OWNED BY pbx_monitora_abdagi.m_id;


--
-- Name: pbx_monitora_sistema_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_monitora_sistema_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_monitora_sistema_id_seq OWNER TO contacte;

--
-- Name: pbx_monitora_sistema; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_monitora_sistema (
    id integer DEFAULT nextval('pbx_monitora_sistema_id_seq'::regclass) NOT NULL,
    tipo_monitor character(10),
    nome_servico character(100),
    avisar_ao_chegar integer,
    enviar_para character varying(2000)
);


ALTER TABLE public.pbx_monitora_sistema OWNER TO contacte;

--
-- Name: pbx_monitoramento_ramais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_monitoramento_ramais (
    ramal character varying(100)
);


ALTER TABLE public.pbx_monitoramento_ramais OWNER TO contacte;

--
-- Name: pbx_motivos_pausas_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_motivos_pausas_id_seq
    START WITH 1
    INCREMENT BY 1
    MAXVALUE 2147483647
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_motivos_pausas_id_seq OWNER TO postgres;

--
-- Name: pbx_municipio_classifica; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_municipio_classifica (
    mun_id integer NOT NULL,
    uf character(2) NOT NULL,
    mun_nome character varying(120) NOT NULL,
    mun_ddd integer
);


ALTER TABLE public.pbx_municipio_classifica OWNER TO simplesip;

--
-- Name: pbx_municipio_classifica_mun_id_seq; Type: SEQUENCE; Schema: public; Owner: simplesip
--

CREATE SEQUENCE pbx_municipio_classifica_mun_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_municipio_classifica_mun_id_seq OWNER TO simplesip;

--
-- Name: pbx_municipio_classifica_mun_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: simplesip
--

ALTER SEQUENCE pbx_municipio_classifica_mun_id_seq OWNED BY pbx_municipio_classifica.mun_id;


--
-- Name: pbx_municipio_prefixo; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_municipio_prefixo (
    mun_id integer NOT NULL,
    prx_prefixo integer NOT NULL
);


ALTER TABLE public.pbx_municipio_prefixo OWNER TO simplesip;

--
-- Name: pbx_municipios; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_municipios (
    id integer NOT NULL,
    uf character(2) NOT NULL,
    sigla_area character varying(4),
    codigo_localidade integer,
    nome_localidade character varying(50) NOT NULL,
    nome_municipio character varying(50) NOT NULL,
    areatarifacao character varying(5),
    prefixo integer NOT NULL,
    nome_operadora character varying(30),
    faixa_inicial integer NOT NULL,
    faixa_final integer NOT NULL,
    latitude character varying(8),
    hemisferio character varying(5),
    longitude character varying(8),
    sigla_area_local character varying(4),
    codigo_ddd integer
);


ALTER TABLE public.pbx_municipios OWNER TO simplesip;

--
-- Name: pbx_municipios_id_seq; Type: SEQUENCE; Schema: public; Owner: simplesip
--

CREATE SEQUENCE pbx_municipios_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_municipios_id_seq OWNER TO simplesip;

--
-- Name: pbx_municipios_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: simplesip
--

ALTER SEQUENCE pbx_municipios_id_seq OWNED BY pbx_municipios.id;


--
-- Name: pbx_musichold_grupos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_musichold_grupos (
    id integer DEFAULT nextval('musichold_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    mode character varying(100) DEFAULT 'files'::character varying,
    directory character varying(100),
    random character varying(3) DEFAULT 'yes'::character varying
);


ALTER TABLE public.pbx_musichold_grupos OWNER TO contacte;

--
-- Name: pbx_nao_classificado; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_nao_classificado AS
    SELECT a.id_bilhetes, a.data_bilhete, a.calldate, rtrim((a.src)::text) AS origem, rtrim((a.dst)::text) AS destino, rtrim((a.uniqueid)::text) AS uniqueid, a.duration, a.billsec, rtrim((a.userfield)::text) AS audio, c.id AS fila_id, rtrim((b.fila)::text) AS fila, "substring"((b.agente)::text, 7, 4) AS agente, d.apelido AS nome_agente, rtrim((b.evento)::text) AS evento, rtrim((b.param1)::text) AS espera, rtrim((b.param2)::text) AS tempo_atendimento FROM pbx_bilhetes a, pbx_eventos_dacs b, pbx_dacs c, pbx_usuarios d WHERE (((((((b.uid2)::text = (a.uniqueid)::text) AND ((c.nome)::text = (b.fila)::text)) AND ((d.matricula)::text = "substring"((b.agente)::text, 7, 4))) AND ((a.lastapp)::text <> 'Transferred Call'::text)) AND ((b.evento)::text = ANY (ARRAY[('COMPLETEAGENT'::character varying)::text, ('COMPLETECALLER'::character varying)::text, ('COMPLETAAGENT'::character varying)::text, ('COMPLETACALLER'::character varying)::text, ('TRANSFER'::character varying)::text, ('TRANSFERORIG'::character varying)::text]))) AND (NOT (EXISTS (SELECT '' FROM pbx_classifica_reg WHERE ((pbx_classifica_reg.id_bilhetes)::text = (a.uniqueid)::text)))));


ALTER TABLE public.pbx_nao_classificado OWNER TO contacte;

--
-- Name: pbx_nao_perturbe; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_nao_perturbe (
    numero character varying(32)
);


ALTER TABLE public.pbx_nao_perturbe OWNER TO contacte;

--
-- Name: pbx_nao_perturbe_cliente; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_nao_perturbe_cliente (
    npc_id integer NOT NULL,
    np_id integer NOT NULL,
    emp_id integer NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_nao_perturbe_cliente OWNER TO contacte;

--
-- Name: pbx_nao_perturbe_cliente_npc_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_nao_perturbe_cliente_npc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_nao_perturbe_cliente_npc_id_seq OWNER TO contacte;

--
-- Name: pbx_nao_perturbe_cliente_npc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_nao_perturbe_cliente_npc_id_seq OWNED BY pbx_nao_perturbe_cliente.npc_id;


--
-- Name: pbx_nao_perturbe_controle; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_nao_perturbe_controle (
    np_id bigint NOT NULL,
    np_data date NOT NULL,
    np_original character varying(64),
    np_nome character varying(64),
    np_path character varying(128),
    np_num_linhas integer,
    np_md5 character varying(32),
    np_proc integer DEFAULT 0 NOT NULL,
    np_log character varying(4096),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_nao_perturbe_controle OWNER TO contacte;

--
-- Name: pbx_nao_perturbe_controle_np_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_nao_perturbe_controle_np_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_nao_perturbe_controle_np_id_seq OWNER TO contacte;

--
-- Name: pbx_nao_perturbe_controle_np_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_nao_perturbe_controle_np_id_seq OWNED BY pbx_nao_perturbe_controle.np_id;


--
-- Name: pbx_normaliza_agenda; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_normaliza_agenda (
    id integer NOT NULL,
    data_norm timestamp without time zone DEFAULT now(),
    ip_servidores character varying(255),
    porta_servidores character varying(255)
);


ALTER TABLE public.pbx_normaliza_agenda OWNER TO contacte;

--
-- Name: pbx_normaliza_agenda_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_normaliza_agenda_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_normaliza_agenda_id_seq OWNER TO contacte;

--
-- Name: pbx_normaliza_agenda_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_normaliza_agenda_id_seq OWNED BY pbx_normaliza_agenda.id;


--
-- Name: pbx_notifica_media; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_notifica_media (
    id integer NOT NULL,
    uniqueid character varying NOT NULL,
    src character varying NOT NULL,
    msg character varying NOT NULL,
    notif_date timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_notifica_media OWNER TO contacte;

--
-- Name: pbx_notifica_media_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_notifica_media_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_notifica_media_id_seq OWNER TO contacte;

--
-- Name: pbx_notifica_media_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_notifica_media_id_seq OWNED BY pbx_notifica_media.id;


--
-- Name: pbx_rotas_saida_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_rotas_saida_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_rotas_saida_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_rotas_saida; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_rotas_saida (
    id integer DEFAULT nextval('pbx_rotas_saida_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    musica_espera character varying(1),
    musica character varying(100),
    anuncio character varying(100),
    operadora character varying(3),
    recorte numeric(9,0),
    acrescenta character varying(100),
    tipo character varying(1),
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_rotas_saida OWNER TO contacte;

--
-- Name: voicemail_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE voicemail_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.voicemail_id_seq OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_voicemail_usuarios; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_voicemail_usuarios (
    id integer DEFAULT nextval('voicemail_id_seq'::regclass) NOT NULL,
    caixa_postal character varying(10),
    senha character varying(100),
    email character varying(100),
    nome character varying(100),
    pager character varying(100),
    saycid character varying(3),
    attach character varying(3),
    delete character varying(3),
    envelope character varying(3),
    tipo character varying(10),
    numero_ramal character varying(100)
);


ALTER TABLE public.pbx_voicemail_usuarios OWNER TO contacte;

--
-- Name: pbx_opcao_acao; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_opcao_acao AS
    (((((((((((SELECT 'ramal'::text AS opcao, (pbx_sip_ramais.nome)::text AS id, pbx_sip_ramais.nome AS descricao FROM pbx_sip_ramais WHERE ((pbx_sip_ramais.nome)::text <> '0'::text) UNION ALL SELECT 'ura'::text AS opcao, (pbx_ura.id)::text AS id, pbx_ura.nome AS descricao FROM pbx_ura) UNION ALL SELECT 'voice'::text AS opcao, (pbx_voicemail_usuarios.caixa_postal)::text AS id, pbx_voicemail_usuarios.caixa_postal AS descricao FROM pbx_voicemail_usuarios) UNION ALL SELECT 'grupo'::text AS opcao, (pbx_grupos.numero)::text AS id, pbx_grupos.descricao FROM pbx_grupos) UNION ALL SELECT 'filas'::text AS opcao, (pbx_queues_grupos.numero)::text AS id, pbx_queues_grupos.nome AS descricao FROM pbx_queues_grupos WHERE (pbx_queues_grupos.status = 'A'::bpchar)) UNION ALL SELECT 'horarios'::text AS opcao, (a.id)::text AS id, a.nome AS descricao FROM pbx_horarios a, pbx_horarios_itens b WHERE (b.id_horario = a.id)) UNION ALL SELECT 'disa'::text AS opcao, (pbx_disa.numero)::text AS id, pbx_disa.numero AS descricao FROM pbx_disa) UNION ALL SELECT 'anuncios'::text AS opcao, (pbx_anuncios.id)::text AS id, pbx_anuncios.nome AS descricao FROM pbx_anuncios) UNION ALL SELECT 'conferencia'::text AS opcao, (pbx_conferencia.numero)::text AS id, pbx_conferencia.numero AS descricao FROM pbx_conferencia) UNION ALL SELECT 'callback'::text AS opcao, (pbx_callback.id)::text AS id, pbx_callback.descricao FROM pbx_callback) UNION ALL SELECT 'rotaInterna'::text AS opcao, (pbx_rotas_saida.id)::text AS id, pbx_rotas_saida.nome AS descricao FROM pbx_rotas_saida WHERE (upper((pbx_rotas_saida.tipo)::text) = 'I'::text)) UNION ALL SELECT 'departamento'::text AS opcao, (a.id)::text AS id, (((b.nome)::text || '/'::text) || (a.nome_depto)::text) AS descricao FROM pbx_departamentos a, pbx_empresa b WHERE (b.id = a.empresa)) UNION ALL SELECT 'integativa'::text AS opcao, (b.itgm_id)::text AS id, (((a.itgc_nome)::text || '-'::text) || (b.itgm_nome)::text) AS descricao FROM pbx_integracao_configuracao a, pbx_integracao_metodo b WHERE ((b.itgc_id = a.itgc_id) AND (b.itgm_retorno = 1)) ORDER BY 3;


ALTER TABLE public.pbx_opcao_acao OWNER TO contacte;

--
-- Name: pbx_opcoes; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_opcoes AS
    (((((((((((((SELECT 'ramal'::character varying(100) AS value, 'Ramal'::character varying(100) AS name FROM pbx_sip_ramais LIMIT 1) UNION ALL (SELECT 'filas'::character varying(100) AS value, 'Fila'::character varying(100) AS name FROM pbx_queues_grupos WHERE (pbx_queues_grupos.status = 'A'::bpchar) LIMIT 1)) UNION ALL (SELECT 'ura'::character varying(100) AS value, 'URA'::character varying(100) AS name FROM pbx_ura LIMIT 1)) UNION ALL (SELECT 'voice'::character varying(100) AS value, 'VoiceMail'::character varying(100) AS name FROM pbx_voicemail_usuarios LIMIT 1)) UNION ALL (SELECT 'grupo'::character varying(100) AS value, 'Grupo'::character varying(100) AS name FROM pbx_grupos LIMIT 1)) UNION ALL (SELECT 'disa'::character varying(100) AS value, 'Disa'::character varying(100) AS name FROM pbx_disa LIMIT 1)) UNION ALL (SELECT 'horarios'::character varying(100) AS value, 'Horários'::character varying(100) AS name FROM pbx_horarios LIMIT 1)) UNION ALL (SELECT 'anuncios'::character varying(100) AS value, 'Anúncios'::character varying(100) AS name FROM pbx_anuncios LIMIT 1)) UNION ALL (SELECT 'conferencia'::character varying(100) AS value, 'Conferências'::character varying(100) AS name FROM pbx_conferencia LIMIT 1)) UNION ALL (SELECT 'callback'::character varying(100) AS value, 'CallBack'::character varying(100) AS name FROM pbx_callback LIMIT 1)) UNION ALL (SELECT 'rotaInterna'::character varying(100) AS value, 'Rotas Internas'::character varying(100) AS name FROM pbx_rotas_saida WHERE ((pbx_rotas_saida.tipo)::text = 'I'::text) LIMIT 1)) UNION ALL (SELECT 'repetir'::character varying(100) AS value, 'Repetir'::character varying(100) AS name FROM pbx_rotas_saida LIMIT 1)) UNION ALL (SELECT 'desligar'::character varying(100) AS value, 'Desligar'::character varying(100) AS name FROM pbx_rotas_saida LIMIT 1)) UNION ALL (SELECT 'integativa'::character varying(100) AS value, 'Integração Ativa'::character varying(100) AS name FROM pbx_integracao_configuracao a, pbx_integracao_metodo b WHERE (b.itgc_id = a.itgc_id) LIMIT 1);


ALTER TABLE public.pbx_opcoes OWNER TO contacte;

--
-- Name: pbx_operadora_rel; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_operadora_rel (
    oper_spid integer NOT NULL,
    oper_spid_rel integer NOT NULL
);


ALTER TABLE public.pbx_operadora_rel OWNER TO contacte;

--
-- Name: pbx_operadoras; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_operadoras (
    oper_id integer NOT NULL,
    oper_nome character varying(100) NOT NULL,
    oper_spid integer NOT NULL,
    oper_licensa character varying(10) DEFAULT '0'::character varying NOT NULL,
    oper_numero character varying(4),
    oper_numero_saida character varying(4),
    oper_dono character(1) DEFAULT 'R'::bpchar NOT NULL
);


ALTER TABLE public.pbx_operadoras OWNER TO contacte;

--
-- Name: pbx_operadoras_oper_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_operadoras_oper_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_operadoras_oper_id_seq OWNER TO contacte;

--
-- Name: pbx_operadoras_oper_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_operadoras_oper_id_seq OWNED BY pbx_operadoras.oper_id;


--
-- Name: pbx_parametros; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_parametros (
    id integer NOT NULL,
    prm_slogan character varying(255),
    prm_path_audio character varying(255),
    prm_path_arq_agente character varying(255),
    prm_logo_relatorio character varying(255),
    prm_relatorio_head character varying(255),
    prm_relatorio_linha1 character varying(255),
    prm_relatorio_linha2 character varying(255),
    prm_agente_atualiza integer DEFAULT 5,
    prm_super_atualiza integer DEFAULT 5,
    prm_agente_classifica integer DEFAULT 0,
    prm_msg_senha_def character varying(255),
    prm_msg_senha_exp character varying(255),
    prm_url_asterisk character varying(255),
    prm_agente_proto integer DEFAULT 0 NOT NULL,
    prm_agente_contribuinte integer DEFAULT 0 NOT NULL,
    prm_ddd_padrao integer DEFAULT 0,
    prm_mun_padrao character varying(50),
    prm_uf_padrao character varying(2),
    prm_cadastro_atendidos character varying(50) DEFAULT 'Clientes'::character varying NOT NULL,
    prm_sk_host character varying(25) DEFAULT '127.0.0.1'::character varying NOT NULL,
    prm_sk_port character varying(11) DEFAULT '5038'::character varying NOT NULL,
    prm_sk_login character varying(120) DEFAULT 'manager'::character varying NOT NULL,
    prm_sk_password character varying(25) DEFAULT 'manager007'::character varying NOT NULL,
    prm_digitos_conta integer DEFAULT 4 NOT NULL,
    prm_digitos_senha integer DEFAULT 4 NOT NULL,
    prm_gera_conta integer DEFAULT 1 NOT NULL,
    prm_super_alerta_atende integer DEFAULT 0 NOT NULL,
    prm_super_alerta_pausa integer DEFAULT 0 NOT NULL,
    prm_super_alerta_livre integer DEFAULT 0 NOT NULL,
    prm_pausa_grupo integer DEFAULT 0 NOT NULL,
    prm_atende_auto integer DEFAULT 1 NOT NULL,
    prm_atende_manual integer DEFAULT 1 NOT NULL,
    prm_atende_preferencial integer DEFAULT 1 NOT NULL,
    prm_classifica_municipio integer DEFAULT 0 NOT NULL,
    prm_tarifador_host character varying(25),
    prm_tarifador_port character varying(11),
    prm_max_agente_pausa integer DEFAULT 0 NOT NULL,
    prm_disponivel_fila integer DEFAULT 1 NOT NULL,
    prm_sk_host_externo character varying(50),
    prm_prefixo_sennha_ramal character varying(50) DEFAULT 'SIP'::character varying NOT NULL,
    prm_exige_classificacao integer DEFAULT 0 NOT NULL,
    prm_boloco_notas_key integer DEFAULT 1 NOT NULL,
    prm_obs_pausaprod integer DEFAULT 0 NOT NULL,
    prm_modulo_pesquisa integer DEFAULT 0 NOT NULL,
    prm_contasenha_sinc integer DEFAULT 0 NOT NULL,
    prm_contasenha_master integer DEFAULT 0 NOT NULL,
    prm_portabilidade integer DEFAULT 0 NOT NULL,
    prm_tarifacao integer DEFAULT 0 NOT NULL,
    prm_prepago integer DEFAULT 0 NOT NULL,
    autologoff character varying(3) DEFAULT ''::character varying NOT NULL,
    autologoffunavail character(3) DEFAULT 'yes'::bpchar NOT NULL,
    endcall character varying(3) DEFAULT 'no'::character varying NOT NULL,
    custom_beep character varying(32) DEFAULT 'beep'::character varying NOT NULL,
    maxlogintries integer DEFAULT 5 NOT NULL,
    ackcall character varying(3) DEFAULT 'no'::character varying NOT NULL,
    wrapuptime integer DEFAULT 0 NOT NULL,
    musiconhold character varying(100) DEFAULT 'agentes'::character varying NOT NULL,
    goodbye character varying(100) DEFAULT ''::character varying NOT NULL,
    updatecdr character varying(3) DEFAULT 'no'::character varying NOT NULL,
    "group" integer DEFAULT 1 NOT NULL,
    recordagentcalls character varying(3) DEFAULT 'no'::character varying,
    recordformat character varying(100) DEFAULT ''::character varying NOT NULL,
    urlprefix character varying(100) DEFAULT ''::character varying NOT NULL,
    savecallsin character varying(100) DEFAULT ''::character varying NOT NULL,
    persistentagents character varying(3) DEFAULT 'no'::character varying,
    multiplelogin character varying(3) DEFAULT 'no'::character varying,
    prm_use_discador integer DEFAULT 0 NOT NULL,
    prm_tempo_sessao integer DEFAULT 20 NOT NULL,
    prm_agente_nova_janela integer DEFAULT 1 NOT NULL,
    prm_label_protoco_pesquisa character varying(128) DEFAULT 'Protocolo'::character varying NOT NULL,
    prm_label_protoco_texto character varying(128) DEFAULT 'Digite um Texto'::character varying NOT NULL,
    prm_label_protoco_grid character varying(128) DEFAULT 'Protocolo'::character varying NOT NULL,
    prm_registro_pagina integer DEFAULT 20 NOT NULL,
    prm_use_vendas integer DEFAULT 0 NOT NULL,
    prm_nome_vendas character varying(30) DEFAULT 'Vendas'::character varying NOT NULL,
    prm_exige_proto_vendas integer DEFAULT 0 NOT NULL,
    prm_alerta_classificacao integer DEFAULT 30 NOT NULL,
    prm_bloqueio integer DEFAULT 0 NOT NULL,
    prm_bloqueio_data date,
    prm_abandonada_semretorno integer DEFAULT 0 NOT NULL,
    prm_max_licenca integer DEFAULT 0 NOT NULL,
    prm_max_ramal integer DEFAULT 0 NOT NULL,
    prm_use_proto_parceiro integer DEFAULT 0 NOT NULL,
    prm_ativa_integracao integer DEFAULT 0 NOT NULL,
    prm_select_integracao integer,
    prm_aviso_desconnect character varying(5) DEFAULT 'yes'::character varying NOT NULL,
    prm_normaliza_agenda integer DEFAULT 0,
    prm_validacao_protocolo character varying(255),
    prm_max_dias_relatorio integer DEFAULT 0,
    prm_restringe_audio integer,
    prm_link_audio character varying(255),
    prm_super_alerta_pausa_checkebox integer DEFAULT 0 NOT NULL,
    prm_ocultar_telefone integer DEFAULT 0,
    prm_ocultar_email integer DEFAULT 0,
    prm_ocultar_documento integer DEFAULT 0,
    prm_sk_host_chat character varying(50),
    prm_chat_api character varying(50),
    prm_chat_atendimento integer DEFAULT 3,
    prm_media_simultaneo integer DEFAULT 3,
    prm_chat_api_supervisor character varying(255)
);


ALTER TABLE public.pbx_parametros OWNER TO postgres;

--
-- Name: pbx_pausa_automatica; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_pausa_automatica (
    iddac integer NOT NULL
);


ALTER TABLE public.pbx_pausa_automatica OWNER TO simplesip;

--
-- Name: pbx_pausa_grupo_usuario; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_pausa_grupo_usuario (
    id integer NOT NULL,
    gp_id integer NOT NULL
);


ALTER TABLE public.pbx_pausa_grupo_usuario OWNER TO simplesip;

--
-- Name: pbx_pausa_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_pausa_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_pausa_id_seq OWNER TO postgres;

--
-- Name: pbx_pbx_centro_custo_ramais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pbx_centro_custo_ramais (
    cc_id integer NOT NULL,
    ramal character varying(30) NOT NULL
);


ALTER TABLE public.pbx_pbx_centro_custo_ramais OWNER TO contacte;

--
-- Name: pbx_permissoes_discagem; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_permissoes_discagem (
    id integer DEFAULT nextval(('"public"."pbx_permissoes_discagem_id_seq"'::text)::regclass) NOT NULL,
    id_usuario integer NOT NULL,
    local_fixo boolean DEFAULT false NOT NULL,
    local_celular boolean DEFAULT false NOT NULL,
    inter_fixo boolean DEFAULT false NOT NULL,
    inter_celular boolean DEFAULT false NOT NULL,
    internacional boolean DEFAULT false NOT NULL,
    perm_especial boolean DEFAULT false NOT NULL,
    grava_ligacao boolean DEFAULT true NOT NULL,
    temporizacao integer NOT NULL,
    data_atualizacao timestamp(6) without time zone DEFAULT now(),
    flag integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_permissoes_discagem OWNER TO postgres;

--
-- Name: pbx_permissoes_discagem_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_permissoes_discagem_id_seq
    START WITH 1
    INCREMENT BY 1
    MAXVALUE 2147483647
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_permissoes_discagem_id_seq OWNER TO postgres;

--
-- Name: pbx_pesquisa_liberacao_dacs; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_liberacao_dacs (
    pl_id integer NOT NULL,
    id_dac integer NOT NULL
);


ALTER TABLE public.pbx_pesquisa_liberacao_dacs OWNER TO contacte;

--
-- Name: pbx_pesquisa_liberacao_pl_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_pesquisa_liberacao_pl_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_pesquisa_liberacao_pl_id_seq OWNER TO contacte;

--
-- Name: pbx_pesquisa_liberacao_pl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_pesquisa_liberacao_pl_id_seq OWNED BY pbx_pesquisa_liberacao.pl_id;


--
-- Name: pbx_pesquisa_log; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_log (
    plog_id bigint NOT NULL,
    plog_data date DEFAULT (now())::date NOT NULL,
    uniqueid character varying(32) NOT NULL,
    matricula character varying(10),
    plog_log text,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    id_dac integer NOT NULL,
    fila character varying(128) NOT NULL,
    pl_id integer NOT NULL,
    integra_vendas integer DEFAULT 0
);


ALTER TABLE public.pbx_pesquisa_log OWNER TO contacte;

--
-- Name: pbx_pesquisa_log_plog_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_pesquisa_log_plog_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_pesquisa_log_plog_id_seq OWNER TO contacte;

--
-- Name: pbx_pesquisa_log_plog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_pesquisa_log_plog_id_seq OWNED BY pbx_pesquisa_log.plog_id;


--
-- Name: pbx_pesquisa_movimento_pm_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_pesquisa_movimento_pm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_pesquisa_movimento_pm_id_seq OWNER TO contacte;

--
-- Name: pbx_pesquisa_movimento_pm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_pesquisa_movimento_pm_id_seq OWNED BY pbx_pesquisa_movimento.pm_id;


--
-- Name: pbx_pesquisa_opcoes_po_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_pesquisa_opcoes_po_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_pesquisa_opcoes_po_id_seq OWNER TO contacte;

--
-- Name: pbx_pesquisa_opcoes_po_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_pesquisa_opcoes_po_id_seq OWNED BY pbx_pesquisa_opcoes.po_id;


--
-- Name: pbx_pesquisa_pp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_pesquisa_pp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_pesquisa_pp_id_seq OWNER TO contacte;

--
-- Name: pbx_pesquisa_pp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_pesquisa_pp_id_seq OWNED BY pbx_pesquisa.pp_id;


--
-- Name: pbx_pesquisa_questao_tipo; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_questao_tipo (
    pqt_id integer NOT NULL,
    pqt_descricao character varying(60) NOT NULL,
    user_reg character varying(20),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    pqt_status integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_pesquisa_questao_tipo OWNER TO contacte;

--
-- Name: pbx_pesquisa_questoes_pq_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_pesquisa_questoes_pq_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_pesquisa_questoes_pq_id_seq OWNER TO contacte;

--
-- Name: pbx_pesquisa_questoes_pq_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_pesquisa_questoes_pq_id_seq OWNED BY pbx_pesquisa_questoes.pq_id;


--
-- Name: pbx_pesquisa_regitra; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_pesquisa_regitra (
    uniqueid character varying(32) NOT NULL,
    id_dac integer,
    matricula character varying(10),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    data_fim timestamp without time zone
);


ALTER TABLE public.pbx_pesquisa_regitra OWNER TO contacte;

--
-- Name: pbx_prepago; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_prepago AS
    ((SELECT 0 AS tipo, 'sip'::text AS desc_tipo, (pbx_sip_ramais.nome)::text AS id, 'pbx_sip_ramais'::text AS tabela, 'nome'::text AS coluna, pbx_sip_ramais.habilita_prepago, pbx_sip_ramais.saldo_prepago FROM pbx_sip_ramais UNION ALL SELECT 0 AS tipo, 'iax'::text AS desc_tipo, (pbx_iax_pbx.nome)::text AS id, 'pbx_iax_pbx'::text AS tabela, 'nome'::text AS coluna, pbx_iax_pbx.habilita_prepago, pbx_iax_pbx.saldo_prepago FROM pbx_iax_pbx) UNION ALL SELECT 0 AS tipo, 'dgv'::text AS desc_tipo, (pbx_dgv.numero)::text AS id, 'pbx_dgv'::text AS tabela, 'numero'::text AS coluna, pbx_dgv.habilita_prepago, pbx_dgv.saldo_prepago FROM pbx_dgv) UNION ALL SELECT 1 AS tipo, 'conta'::text AS desc_tipo, (pbx_cs_usuarios.matricula)::text AS id, 'pbx_cs_usuarios'::text AS tabela, 'matricula'::text AS coluna, pbx_cs_usuarios.habilita_prepago, pbx_cs_usuarios.saldo_prepago FROM pbx_cs_usuarios WHERE (pbx_cs_usuarios.status = 'A'::bpchar);


ALTER TABLE public.pbx_prepago OWNER TO contacte;

--
-- Name: pbx_prepago_movimento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_prepago_movimento (
    prm_id bigint NOT NULL,
    prm_ramal_conta character varying(11) NOT NULL,
    prm_conta_senha integer DEFAULT 1 NOT NULL,
    trr_id bigint,
    prm_valor_minuto numeric(12,4),
    prm_tempo integer,
    prm_destino character varying(30),
    prm_valor numeric(12,2),
    prm_data date,
    prm_data_lanc timestamp without time zone,
    prm_tipo_lancamento character(1),
    prm_historico character varying(255),
    usuario character varying(30)
);


ALTER TABLE public.pbx_prepago_movimento OWNER TO contacte;

--
-- Name: pbx_prepago_movimento_prm_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_prepago_movimento_prm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_prepago_movimento_prm_id_seq OWNER TO contacte;

--
-- Name: pbx_prepago_movimento_prm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_prepago_movimento_prm_id_seq OWNED BY pbx_prepago_movimento.prm_id;


--
-- Name: pbx_prioridades_atendimento_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_prioridades_atendimento_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_prioridades_atendimento_id_seq OWNER TO contacte;

--
-- Name: pbx_prioridades_atendimento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_prioridades_atendimento (
    id integer DEFAULT nextval('pbx_prioridades_atendimento_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    telefone character varying(11),
    seq integer,
    dac character varying(30)
);


ALTER TABLE public.pbx_prioridades_atendimento OWNER TO contacte;

--
-- Name: pbx_protocolo_reg; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_protocolo_reg (
    uniqueid character varying(32) NOT NULL,
    ano integer DEFAULT 0 NOT NULL,
    numproto integer DEFAULT 0 NOT NULL,
    protocolo bigint DEFAULT 0 NOT NULL,
    "dataReg" timestamp without time zone DEFAULT now() NOT NULL,
    protoparceiro character varying(64),
    protointegrado integer DEFAULT 0 NOT NULL,
    integra_vendas integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_protocolo_reg OWNER TO postgres;

--
-- Name: pbx_queues_general; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_queues_general (
    persistentmembers character varying(3),
    autofill character varying(3),
    setinterfacevar character varying(3),
    "monitor-type" character varying(100)
);


ALTER TABLE public.pbx_queues_general OWNER TO contacte;

--
-- Name: pbx_queues_grupos_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_queues_grupos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_queues_grupos_id_seq OWNER TO contacte;

--
-- Name: pbx_queues_grupos_mesa; Type: VIEW; Schema: public; Owner: simplesip
--

CREATE VIEW pbx_queues_grupos_mesa AS
    SELECT pbx_queues_grupos.id, pbx_queues_grupos.nome FROM pbx_queues_grupos WHERE (pbx_queues_grupos.status = 'A'::bpchar) ORDER BY pbx_queues_grupos.nome;


ALTER TABLE public.pbx_queues_grupos_mesa OWNER TO simplesip;

--
-- Name: VIEW pbx_queues_grupos_mesa; Type: COMMENT; Schema: public; Owner: simplesip
--

COMMENT ON VIEW pbx_queues_grupos_mesa IS 'VIEW UTILIZADA PARA PEGAR TODAS AS DESCRIÇOES DE FILA.
UTILIZADA A VIEW PARA CONTROLE DE ACESSO';


--
-- Name: pbx_queues_membros_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_queues_membros_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_queues_membros_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_queues_membros; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_queues_membros (
    id integer DEFAULT nextval('pbx_queues_membros_id_seq'::regclass) NOT NULL,
    id_fila integer,
    dispositivo character varying(100),
    prioridade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_queues_membros OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_ramais_pbx; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_ramais_pbx (
    id integer NOT NULL,
    senha integer,
    dispositivo character varying(250),
    voicemail character varying(20),
    senha_v character varying(20),
    usuario_v character varying(20),
    contexto character varying(20),
    grupo character varying(20),
    immediate character varying(20) DEFAULT NULL::character varying,
    accountcode character varying(100),
    capturar character varying(100),
    espera character varying(1),
    sigame_interno character varying(20),
    sigame_externo character varying(20),
    sigame_naoatende character varying(20),
    sigame_ocupado character varying(20),
    gravacao_chamada character varying(1),
    musica_espera character varying(100),
    nao_pertube character varying(1),
    cadeado character varying(1),
    gravacao_saida character varying(1),
    senha_facilidade character varying(100),
    identificador character varying(100),
    numero character varying(10),
    identificador2 character varying(100),
    conta_senha character varying(1) DEFAULT 'V'::character varying NOT NULL,
    ramalsecretaria character varying(20),
    saldo_prepago numeric(12,4) DEFAULT 0,
    habilita_prepago integer DEFAULT 0 NOT NULL,
    ring_time character varying(100),
    timeout character varying(16)
);


ALTER TABLE public.pbx_ramais_pbx OWNER TO contacte;

--
-- Name: pbx_ramais; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_ramais AS
    (SELECT a.id, 'SIP'::character varying(16) AS tipo_ramal, a.nome, a.dispositivo, a.context AS contexto, a.habilita_prepago, a.saldo_prepago, a.ramalsecretaria, a.sigame_interno, a.sigame_externo, a.sigame_naoatende, a.sigame_ocupado, a.extranet FROM pbx_sip_ramais a UNION ALL SELECT b.id, 'IAX2'::character varying(16) AS tipo_ramal, b.nome, b.dispositivo, b.context AS contexto, b.habilita_prepago, b.saldo_prepago, b.ramalsecretaria, b.sigame_interno, b.sigame_externo, b.sigame_naoatende, b.sigame_ocupado, ''::character varying(256) AS extranet FROM pbx_iax_pbx b) UNION ALL SELECT c.id, 'PBX'::text AS tipo_ramal, c.numero AS nome, (((c.dispositivo)::text || '/'::text) || (c.numero)::text) AS dispositivo, c.contexto, c.habilita_prepago, c.saldo_prepago, c.ramalsecretaria, c.sigame_interno, c.sigame_externo, c.sigame_naoatende, c.sigame_ocupado, ''::character varying(256) AS extranet FROM pbx_ramais_pbx c ORDER BY 1;


ALTER TABLE public.pbx_ramais OWNER TO contacte;

--
-- Name: pbx_ramais_agenda; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_ramais_agenda (
    rma_telefone character varying(250) NOT NULL,
    rma_nome character varying(100),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    user_reg integer DEFAULT 0 NOT NULL,
    ddd character varying(2)
);


ALTER TABLE public.pbx_ramais_agenda OWNER TO simplesip;

--
-- Name: pbx_ramais_mesa; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_ramais_mesa AS
    SELECT 0 AS tipo, pbx_sip_ramais.id, pbx_sip_ramais.nome, pbx_sip_ramais.dispositivo, pbx_sip_ramais.callerid, 'SIP'::text AS tipo_table, pbx_sip_ramais.conta_senha, ''::character varying AS ddd, pbx_sip_ramais.context AS contexto FROM pbx_sip_ramais UNION ALL SELECT 1 AS tipo, 0 AS id, pbx_ramais_agenda.rma_telefone AS nome, pbx_ramais_agenda.rma_telefone AS dispositivo, pbx_ramais_agenda.rma_nome AS callerid, 'AGD'::text AS tipo_table, 'F'::character varying AS conta_senha, pbx_ramais_agenda.ddd, ' '::character varying AS contexto FROM pbx_ramais_agenda ORDER BY 1;


ALTER TABLE public.pbx_ramais_mesa OWNER TO contacte;

--
-- Name: pbx_ramais_pbx_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_ramais_pbx_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_ramais_pbx_id_seq OWNER TO contacte;

--
-- Name: pbx_ramais_pbx_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_ramais_pbx_id_seq OWNED BY pbx_ramais_pbx.id;


--
-- Name: pbx_registra_classificacao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_registra_classificacao (
    id_dac integer NOT NULL,
    matricula character varying(4) NOT NULL,
    rgc_entrada timestamp without time zone NOT NULL,
    rgc_saida timestamp without time zone,
    matricula_reg character varying(4),
    uid character varying(32),
    id_login integer,
    reg_proc character varying(1024)
);


ALTER TABLE public.pbx_registra_classificacao OWNER TO contacte;

--
-- Name: pbx_relatorio_filas; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_relatorio_filas (
    "118" bigint,
    "181" bigint,
    "190" bigint,
    "191" bigint,
    "192" bigint,
    "193" bigint,
    "197" bigint,
    data timestamp without time zone,
    data_updated timestamp without time zone
);


ALTER TABLE public.pbx_relatorio_filas OWNER TO contacte;

--
-- Name: pbx_relatorio_ordena; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_relatorio_ordena (
    ord_id integer NOT NULL,
    ord_rel_id integer NOT NULL,
    ord_nome_coluna character varying(80) NOT NULL,
    ord_display_coluna character varying(120) NOT NULL
);


ALTER TABLE public.pbx_relatorio_ordena OWNER TO simplesip;

--
-- Name: pbx_relatorio_ordena_ord_id_seq; Type: SEQUENCE; Schema: public; Owner: simplesip
--

CREATE SEQUENCE pbx_relatorio_ordena_ord_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_relatorio_ordena_ord_id_seq OWNER TO simplesip;

--
-- Name: pbx_relatorio_ordena_ord_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: simplesip
--

ALTER SEQUENCE pbx_relatorio_ordena_ord_id_seq OWNED BY pbx_relatorio_ordena.ord_id;


--
-- Name: pbx_relatorio_ordena_set; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_relatorio_ordena_set (
    ord_id integer NOT NULL,
    ord_rel_id integer NOT NULL,
    ords_seq integer NOT NULL,
    ords_ordem integer NOT NULL
);


ALTER TABLE public.pbx_relatorio_ordena_set OWNER TO simplesip;

--
-- Name: pbx_rename_renameid_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_rename_renameid_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_rename_renameid_seq OWNER TO contacte;

--
-- Name: pbx_rename; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_rename (
    renameid integer DEFAULT nextval('pbx_rename_renameid_seq'::regclass) NOT NULL,
    oldname character varying(80),
    newname character varying(80),
    uniqueid character varying(32)
);


ALTER TABLE public.pbx_rename OWNER TO contacte;

--
-- Name: pbx_replica; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_replica (
    rpl_id bigint NOT NULL,
    rpl_origem character varying(120),
    rpl_command text NOT NULL,
    rpl_user character varying(30),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_replica OWNER TO contacte;

--
-- Name: pbx_replica_host_server_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_replica_host_server_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_replica_host_server_id_seq OWNER TO contacte;

--
-- Name: pbx_replica_host; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_replica_host (
    server_id bigint DEFAULT nextval('pbx_replica_host_server_id_seq'::regclass) NOT NULL,
    rpl_id integer NOT NULL,
    datareg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_replica_host OWNER TO contacte;

--
-- Name: pbx_replica_hosts; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_replica_hosts (
    host_id character varying(25) NOT NULL,
    rpl_id bigint NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_replica_hosts OWNER TO contacte;

--
-- Name: pbx_replica_rpl_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_replica_rpl_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_replica_rpl_id_seq OWNER TO contacte;

--
-- Name: pbx_replica_rpl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_replica_rpl_id_seq OWNED BY pbx_replica.rpl_id;


--
-- Name: pbx_rotas; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_rotas AS
    SELECT 'S'::text AS tipo, pbx_rotas_saida.id, pbx_rotas_saida.nome FROM pbx_rotas_saida UNION ALL SELECT 'E'::text AS tipo, pbx_rotas_entrada.id, pbx_rotas_entrada.nome FROM pbx_rotas_entrada ORDER BY 3;


ALTER TABLE public.pbx_rotas OWNER TO contacte;

--
-- Name: pbx_rotas_entrada_troncos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_rotas_entrada_troncos (
    id_rota integer,
    id_tronco integer,
    tipo character varying(50)
);


ALTER TABLE public.pbx_rotas_entrada_troncos OWNER TO contacte;

--
-- Name: pbx_rotas_saida_canais_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_rotas_saida_canais_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_rotas_saida_canais_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_rotas_saida_canais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_rotas_saida_canais (
    id integer DEFAULT nextval('pbx_rotas_saida_canais_id_seq'::regclass) NOT NULL,
    id_rota integer NOT NULL,
    canal character varying(100),
    recorta integer DEFAULT 0 NOT NULL,
    acrescenta character varying(64)
);


ALTER TABLE public.pbx_rotas_saida_canais OWNER TO contacte;

--
-- Name: pbx_rotas_saida_modelos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_rotas_saida_modelos (
    id_rota integer NOT NULL,
    modelo character varying(100) NOT NULL
);


ALTER TABLE public.pbx_rotas_saida_modelos OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_rotas_saida_ramais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_rotas_saida_ramais (
    id_rota integer NOT NULL,
    ramal character varying(30) NOT NULL,
    tipo_acesso integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_rotas_saida_ramais OWNER TO contacte;

--
-- Name: pbx_sequencia; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_sequencia (
    name_table character varying(120) NOT NULL,
    id bigint DEFAULT 0 NOT NULL,
    comment character varying(255)
);


ALTER TABLE public.pbx_sequencia OWNER TO contacte;

--
-- Name: pbx_servers_sinc; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_servers_sinc (
    server_id integer NOT NULL
);


ALTER TABLE public.pbx_servers_sinc OWNER TO contacte;

--
-- Name: pbx_servicos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_servicos (
    serv_id character varying(64) NOT NULL,
    serv_status smallint DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_servicos OWNER TO contacte;

--
-- Name: pbx_servicos_registra; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_servicos_registra (
    uniqueid character varying(32) NOT NULL,
    serv_id character varying(64) NOT NULL
);


ALTER TABLE public.pbx_servicos_registra OWNER TO contacte;

--
-- Name: pbx_servicos_sistema_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_servicos_sistema_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_servicos_sistema_id_seq OWNER TO contacte;

--
-- Name: pbx_servicos_sistema; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_servicos_sistema (
    id integer DEFAULT nextval('pbx_servicos_sistema_id_seq'::regclass) NOT NULL,
    porta integer,
    servico character varying(100)
);


ALTER TABLE public.pbx_servicos_sistema OWNER TO contacte;

--
-- Name: pbx_sip_general; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_sip_general (
    nome character varying(80),
    context character varying(80),
    callerid character varying(80),
    allowguest character(3),
    allowoverlap character(3),
    allowtransfer character(3),
    realm character varying(80),
    bindport integer,
    bindaddr character varying(80),
    srvlookup character(3),
    pedantic character(3),
    tos_sip character varying(80),
    tos_audio character varying(80),
    tos_video character varying(80),
    maxexpiry integer,
    minexpiry integer,
    notifymimetype character varying(80),
    buggymwi character(3),
    vmexten character varying(80),
    mohinterpret character varying(80),
    mohsuggest character varying(80),
    language character varying(80),
    relaxdtmf character(3),
    trustrpid character(3),
    sendrpid character(3),
    progressinband character(6),
    useragent character varying(80),
    promiscredir character(3),
    userqphone character(3),
    dtmfmode character varying(80),
    compactheaders character(3),
    videosupport character(3),
    alwaysauthreject character(3),
    g726nonstandard character(3),
    matchexterniplocally character(3),
    regcontext character varying(80),
    rtpkeepalive character varying(80),
    sipdebug character(3),
    recordhistory character(3),
    dumphistory character(3),
    allowsubscribe character(3),
    subscribecontext character varying(80),
    notifyringing character(3),
    notifyhold character(3),
    limitonpeers character(3),
    t38pt_udptl character(3),
    externip character varying(80),
    externhost character varying(80),
    localnet character varying(80),
    nat character(10),
    canreinvite character(10),
    directrtpsetup character(3),
    rtcachefriends character(3),
    rtsavesysname character(3),
    rtupdate character(3),
    rtautoclear character(3),
    ignoreregexpire character(3),
    domain character varying(80),
    autodomain character(3),
    allowexternaldomains character(3),
    fromdomain character varying(80),
    jbenable character(3),
    jbforce character(3),
    jbmaxsize character varying(80),
    jbresyncthreshold character varying(80),
    jbimpl character(8),
    jblog character(3),
    auth character varying(80),
    extranet character varying(256)
);


ALTER TABLE public.pbx_sip_general OWNER TO contacte;

--
-- Name: pbx_sites_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_sites_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_sites_id_seq OWNER TO contacte;

--
-- Name: pbx_sites; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_sites (
    id integer DEFAULT nextval('pbx_sites_id_seq'::regclass) NOT NULL,
    host character varying(25) NOT NULL,
    usuario character varying(20),
    senha character varying(50),
    basedados character varying(50),
    porta integer,
    descricao character varying(25),
    status integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.pbx_sites OWNER TO contacte;

--
-- Name: pbx_sms_send; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_sms_send (
    sms_id bigint NOT NULL,
    sms_sip_id character varying(50),
    sms_tronco_envio character varying(30),
    sms_destino character varying(30),
    sms_mensagem character varying(2048),
    sms_status character varying(30),
    sms_cod_erro integer,
    sms_nome_erro character varying(50),
    sms_tronco_saida character varying(30),
    sms_id_envio character varying(50),
    sms_data_envio timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_sms_send OWNER TO contacte;

--
-- Name: pbx_sms_send_sms_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_sms_send_sms_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_sms_send_sms_id_seq OWNER TO contacte;

--
-- Name: pbx_sms_send_sms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_sms_send_sms_id_seq OWNED BY pbx_sms_send.sms_id;


--
-- Name: pbx_status_contato_campanha; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_status_contato_campanha (
    ctst_id integer NOT NULL,
    cmp_id integer NOT NULL
);


ALTER TABLE public.pbx_status_contato_campanha OWNER TO contacte;

--
-- Name: pbx_status_ligacao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_status_ligacao (
    stat_id integer NOT NULL,
    stat_default character varying(50) NOT NULL,
    stat_descricao character varying(50) NOT NULL,
    stat_ret_arquivo character varying(50) NOT NULL
);


ALTER TABLE public.pbx_status_ligacao OWNER TO contacte;

--
-- Name: pbx_status_retorno; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_status_retorno (
    strt_id integer NOT NULL,
    strt_descricao character varying(50) NOT NULL
);


ALTER TABLE public.pbx_status_retorno OWNER TO contacte;

--
-- Name: pbx_supervisor_agentes_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_supervisor_agentes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_supervisor_agentes_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_supervisor_agentes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_supervisor_agentes (
    id bigint DEFAULT nextval('pbx_supervisor_agentes_id_seq'::regclass) NOT NULL,
    ramal character varying(50),
    matricula character varying(4),
    nome character varying(50),
    tempo_login timestamp(0) without time zone,
    modo_atendimento character varying(50),
    dac character varying(50),
    origem_destino character varying(50),
    status character varying(50),
    duracao timestamp(0) without time zone,
    canal character varying(50),
    logado timestamp(0) without time zone,
    uniqueid character varying(32) DEFAULT ''::text,
    intercalar integer DEFAULT 0 NOT NULL,
    monitorar integer DEFAULT 0 NOT NULL,
    cont_identificador character varying(1024),
    sala_1 character varying(10),
    sala_2 character varying(32),
    facilidade character varying(10),
    canal_agente character varying(50),
    canal_transfer character varying(50),
    tipo_ligacao character varying(20),
    status_gravacao character varying(1),
    tipo_discagem character varying(20),
    status_agente integer DEFAULT 0 NOT NULL,
    motivo_pausa character varying(50),
    relaciona_evento integer,
    id_motivo integer,
    status_time timestamp without time zone DEFAULT now() NOT NULL,
    id_eventos_agente integer,
    protocolo character varying(15),
    uniqueid2 character varying(32),
    disponivel_atendimento integer DEFAULT 1 NOT NULL,
    chamada_classificado integer DEFAULT 1 NOT NULL,
    status_discador integer DEFAULT 0 NOT NULL,
    media integer DEFAULT(99)
);


ALTER TABLE public.pbx_supervisor_agentes OWNER TO contacte;

--
-- Name: pbx_supervisor_dacs_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_supervisor_dacs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_supervisor_dacs_id_seq OWNER TO contacte;

--
-- Name: pbx_supervisor_dacs; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_supervisor_dacs (
    id bigint DEFAULT nextval('pbx_supervisor_dacs_id_seq'::regclass) NOT NULL,
    dac character varying(50),
    atendidas character varying(20),
    abandonadas character varying(20),
    espera character varying(20),
    tempo_espera integer,
    tempo_nivel_servico character varying(20),
    percentual_nivel_servico character varying(20),
    originadas integer DEFAULT 0
);


ALTER TABLE public.pbx_supervisor_dacs OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_supervisor_funcoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_supervisor_funcoes (
    fun_nome character varying(50) NOT NULL
);


ALTER TABLE public.pbx_supervisor_funcoes OWNER TO contacte;

--
-- Name: pbx_tab_ddd; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tab_ddd (
    idddd integer NOT NULL,
    uf character(2),
    sigla character varying(10),
    localidade character varying(120),
    municipio character varying(120),
    codigo integer
);


ALTER TABLE public.pbx_tab_ddd OWNER TO contacte;

--
-- Name: pbx_tab_ddd_idddd_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_tab_ddd_idddd_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_tab_ddd_idddd_seq OWNER TO contacte;

--
-- Name: pbx_tab_ddd_idddd_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_tab_ddd_idddd_seq OWNED BY pbx_tab_ddd.idddd;


--
-- Name: pbx_tabelas_check; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tabelas_check (
    nome_tabela character varying(50)
);


ALTER TABLE public.pbx_tabelas_check OWNER TO contacte;

--
-- Name: pbx_tarif_contrato; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_contrato (
    contr_id integer NOT NULL,
    oper_id integer NOT NULL,
    empresa integer NOT NULL,
    contr_tipo character varying(10) DEFAULT 'fixo'::character varying NOT NULL,
    contr_numero character varying(50) NOT NULL,
    contr_descricao character varying(100) NOT NULL,
    contr_dia_fechamento integer DEFAULT 1 NOT NULL,
    contr_tipo_franquia integer DEFAULT 0 NOT NULL,
    contr_bloq_franquia integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_tarif_contrato OWNER TO contacte;

--
-- Name: pbx_tarif_contrato_contr_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_tarif_contrato_contr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_tarif_contrato_contr_id_seq OWNER TO contacte;

--
-- Name: pbx_tarif_contrato_contr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_tarif_contrato_contr_id_seq OWNED BY pbx_tarif_contrato.contr_id;


--
-- Name: pbx_tarif_contrato_preco; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_contrato_preco (
    prc_id integer NOT NULL,
    contr_id integer,
    prc_vigencia date DEFAULT (now())::date NOT NULL,
    prc_tipo_opera integer DEFAULT 0 NOT NULL,
    prc_tipo character varying(10) NOT NULL,
    prc_franquia integer DEFAULT 0 NOT NULL,
    prc_franquia_preco numeric(12,4) DEFAULT 0.0 NOT NULL,
    prc_preco_vc1 numeric(12,4) DEFAULT 0.0 NOT NULL,
    prc_preco_vc2 numeric(12,4) DEFAULT 0.0 NOT NULL,
    prc_preco_vc3 numeric(12,4) DEFAULT 0.0 NOT NULL,
    prc_preco_vc4 numeric(12,4) DEFAULT 0.0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    prc_franquia_movel integer DEFAULT 0 NOT NULL,
    contr_dia_fechamento integer,
    prc_preco_vc5 numeric(12,4) DEFAULT 0.0 NOT NULL,
    prc_preco_vc6 numeric(12,4) DEFAULT 0.0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL,
    [REDACTED] integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_tarif_contrato_preco OWNER TO contacte;

--
-- Name: pbx_tarif_contrato_preco_prc_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_tarif_contrato_preco_prc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_tarif_contrato_preco_prc_id_seq OWNER TO contacte;

--
-- Name: pbx_tarif_contrato_preco_prc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_tarif_contrato_preco_prc_id_seq OWNED BY pbx_tarif_contrato_preco.prc_id;


--
-- Name: pbx_tarif_contrato_tarifa_zero; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_contrato_tarifa_zero (
    contr_id integer NOT NULL,
    trz_numero character varying(27) NOT NULL
);


ALTER TABLE public.pbx_tarif_contrato_tarifa_zero OWNER TO contacte;

--
-- Name: pbx_tarif_franquia; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_franquia (
    contr_id integer NOT NULL,
    tff_mes integer NOT NULL,
    tff_data timestamp without time zone,
    tff_franquia integer,
    tff_saldo integer,
    tff_franquia_movel integer,
    tff_saldo_movel integer,
    contr_dia_fechamento integer
);


ALTER TABLE public.pbx_tarif_franquia OWNER TO contacte;

--
-- Name: pbx_tarif_franquia_movimento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_franquia_movimento (
    tfm_id bigint NOT NULL,
    prc_id integer NOT NULL,
    contr_id integer NOT NULL,
    tfm_mes integer NOT NULL,
    uniqueid character varying(32) NOT NULL,
    tfm_data timestamp without time zone,
    tfm_lanc integer,
    tfm_tipo_lanc character(1),
    tfm_motivo character varying(255),
    tfm_user character varying(30),
    tfm_tipo_franquia integer,
    tmf_tipo_saldo character(1),
    tfm_preco_tipo character varying(10)
);


ALTER TABLE public.pbx_tarif_franquia_movimento OWNER TO contacte;

--
-- Name: pbx_tarif_franquia_movimento_tfm_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_tarif_franquia_movimento_tfm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_tarif_franquia_movimento_tfm_id_seq OWNER TO contacte;

--
-- Name: pbx_tarif_franquia_movimento_tfm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_tarif_franquia_movimento_tfm_id_seq OWNED BY pbx_tarif_franquia_movimento.tfm_id;


--
-- Name: pbx_tarif_registra; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_registra (
    trr_id bigint NOT NULL,
    contr_id integer NOT NULL,
    contr_id_dest integer NOT NULL,
    prc_id integer NOT NULL,
    trr_preco_tipo integer NOT NULL,
    oper_id integer NOT NULL,
    oper_id_dest integer,
    tronco_id integer NOT NULL,
    oper_numero character varying(4),
    oper_numero_dest character varying(4),
    rota_id integer NOT NULL,
    uniqueid character varying(32) NOT NULL,
    trr_tarifa_zero integer DEFAULT 0 NOT NULL,
    trr_conta_senha integer DEFAULT 0 NOT NULL,
    trr_conta character varying(20),
    trr_data date,
    trr_origem character varying(32),
    trr_destino character varying(32),
    trr_inicio timestamp without time zone,
    trr_fim timestamp without time zone,
    trr_fim_transf timestamp without time zone,
    trr_vc character(3),
    trr_vc_cad integer,
    trr_vc_ext integer,
    trr_duracao integer,
    trr_duracao_transf integer,
    trr_preco numeric(12,4),
    trr_preco_total numeric(12,4),
    trr_tipo_opera integer,
    trr_sentido_chamada character(1),
    trr_link character varying(32),
    trr_tipo_chamada character(1),
    datareg timestamp without time zone DEFAULT now() NOT NULL,
    trr_franquia integer DEFAULT 0 NOT NULL,
    trr_tipo_dispositivo character varying(10),
    trr_chamada character varying(10),
    trr_log character varying(255),
    trr_exporta character(1)
);


ALTER TABLE public.pbx_tarif_registra OWNER TO contacte;

--
-- Name: pbx_tarif_registra_trr_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_tarif_registra_trr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_tarif_registra_trr_id_seq OWNER TO contacte;

--
-- Name: pbx_tarif_registra_trr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_tarif_registra_trr_id_seq OWNED BY pbx_tarif_registra.trr_id;


--
-- Name: pbx_tarif_retarifa; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_retarifa (
    ret_data timestamp without time zone NOT NULL,
    trr_id bigint NOT NULL,
    trr_preco_tipo integer,
    trr_preco numeric(12,4),
    trr_vc_cad integer,
    trr_vc_ext integer,
    user_reg character varying(30)
);


ALTER TABLE public.pbx_tarif_retarifa OWNER TO contacte;

--
-- Name: pbx_tarif_tipo_franquia; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarif_tipo_franquia (
    tfq_id integer NOT NULL,
    tfq_descricao character varying(50) NOT NULL
);


ALTER TABLE public.pbx_tarif_tipo_franquia OWNER TO contacte;

--
-- Name: pbx_tarifa_tipo_preco; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tarifa_tipo_preco (
    ttp_id character(3) NOT NULL,
    ttp_descricao character varying(80) NOT NULL
);


ALTER TABLE public.pbx_tarifa_tipo_preco OWNER TO contacte;

--
-- Name: pbx_tarifador_log; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_tarifador_log (
    trf_id integer NOT NULL,
    trf_data date NOT NULL,
    trf_num_reg integer,
    trf_file text,
    trf_exportado integer DEFAULT 0 NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_tarifador_log OWNER TO simplesip;

--
-- Name: pbx_tarifador_log_trf_id_seq; Type: SEQUENCE; Schema: public; Owner: simplesip
--

CREATE SEQUENCE pbx_tarifador_log_trf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_tarifador_log_trf_id_seq OWNER TO simplesip;

--
-- Name: pbx_tarifador_log_trf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: simplesip
--

ALTER SEQUENCE pbx_tarifador_log_trf_id_seq OWNED BY pbx_tarifador_log.trf_id;


--
-- Name: pbx_televendas_bloqueio; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_televendas_bloqueio (
    tlvb_id bigint NOT NULL,
    tlvb_mes integer DEFAULT date_part('month'::text, now()) NOT NULL,
    tlvb_data date DEFAULT (now())::date NOT NULL,
    src character varying(18),
    dst character varying(18),
    tlvb_status integer,
    tlvb_msg character varying(255),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_televendas_bloqueio OWNER TO contacte;

--
-- Name: pbx_televendas_bloqueio_tlvb_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_televendas_bloqueio_tlvb_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_televendas_bloqueio_tlvb_id_seq OWNER TO contacte;

--
-- Name: pbx_televendas_bloqueio_tlvb_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_televendas_bloqueio_tlvb_id_seq OWNED BY pbx_televendas_bloqueio.tlvb_id;


--
-- Name: pbx_televendas_reg; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_televendas_reg (
    tlvb_id bigint NOT NULL,
    tlvb_mes integer DEFAULT date_part('month'::text, now()) NOT NULL,
    tlvb_data date DEFAULT (now())::date NOT NULL,
    src character varying(18),
    dst character varying(18),
    tlvb_status integer,
    tlvb_msg character varying(255),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_televendas_reg OWNER TO contacte;

--
-- Name: pbx_televendas_reg_tlvb_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_televendas_reg_tlvb_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_televendas_reg_tlvb_id_seq OWNER TO contacte;

--
-- Name: pbx_televendas_reg_tlvb_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_televendas_reg_tlvb_id_seq OWNED BY pbx_televendas_reg.tlvb_id;


--
-- Name: pbx_tempo_meta; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tempo_meta (
    tempo integer NOT NULL,
    descricao character varying(50) NOT NULL
);


ALTER TABLE public.pbx_tempo_meta OWNER TO contacte;

--
-- Name: pbx_teste; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_teste (
    id integer NOT NULL,
    entrada character varying(1),
    saida character varying(1),
    numero character varying(100)
);


ALTER TABLE public.pbx_teste OWNER TO postgres;

--
-- Name: pbx_teste_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_teste_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_teste_id_seq OWNER TO postgres;

--
-- Name: pbx_teste_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE pbx_teste_id_seq OWNED BY pbx_teste.id;


--
-- Name: pbx_teste_permissao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_teste_permissao (
    id integer NOT NULL,
    ip_cliente inet,
    data_teste timestamp with time zone,
    status character varying(140),
    mensagem text,
    nome_cliente character varying(140)
);


ALTER TABLE public.pbx_teste_permissao OWNER TO contacte;

--
-- Name: pbx_teste_permissao_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_teste_permissao_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_teste_permissao_id_seq OWNER TO contacte;

--
-- Name: pbx_teste_permissao_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_teste_permissao_id_seq OWNED BY pbx_teste_permissao.id;


--
-- Name: pbx_tipo_ligacao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_tipo_ligacao (
    tplg_codigo integer NOT NULL,
    tplg_descricao character varying(64) NOT NULL,
    tplg_tipo integer NOT NULL
);


ALTER TABLE public.pbx_tipo_ligacao OWNER TO contacte;

--
-- Name: pbx_troncos_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_troncos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_troncos_id_seq OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_troncos_iax; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_troncos_iax (
    id integer DEFAULT nextval('pbx_troncos_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    username character varying(100),
    secret character varying(100),
    type character varying(100),
    context character varying(100),
    callerid character varying(100),
    host character varying(100),
    port character varying(100),
    deny character varying(100),
    permit character varying(100),
    qualify character varying(100),
    nat character varying(100),
    canreinvite character varying(100),
    disallow character varying(100),
    allow character varying(100),
    dtmfmode character varying(100),
    fromuser character varying(100),
    fromdomain character varying(100),
    max_ligacoes integer,
    pedido_registro character varying(3),
    trunk character varying(3),
    registro character varying(100),
    contrato integer DEFAULT 0 NOT NULL,
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_troncos_iax OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_troncos_khomp; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_troncos_khomp (
    id integer DEFAULT nextval('pbx_troncos_id_seq'::regclass) NOT NULL,
    descricao character varying(100),
    grupo character varying(30) NOT NULL,
    porta character varying(30) NOT NULL,
    contexto character varying(30) NOT NULL,
    contrato integer DEFAULT 0 NOT NULL,
    callerid character varying(100),
    max_ligacoes integer DEFAULT 30 NOT NULL,
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_troncos_khomp OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_troncos_sip; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_troncos_sip (
    id integer DEFAULT nextval('pbx_troncos_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    username character varying(100),
    secret character varying(100),
    type character varying(100),
    context character varying(100),
    callerid character varying(100),
    host character varying(100),
    port character varying(100),
    deny character varying(100),
    permit character varying(100),
    qualify character varying(100),
    nat character varying(100),
    canreinvite character varying(100),
    disallow character varying(100),
    allow character varying(100),
    dtmfmode character varying(100),
    fromuser character varying(100),
    fromdomain character varying(100),
    max_ligacoes integer,
    pedido_registro character varying(3),
    registro character varying(100),
    contrato integer DEFAULT 0 NOT NULL,
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_troncos_sip OWNER TO contacte;

--
-- Name: pbx_troncos; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_troncos AS
    (SELECT 'SIP'::text AS tipo, pbx_troncos_sip.id, pbx_troncos_sip.nome, pbx_troncos_sip.max_ligacoes, pbx_troncos_sip.nome AS username, pbx_troncos_sip.contrato, pbx_troncos_sip.callerid, pbx_troncos_sip.context, pbx_troncos_sip.callerid AS callerid_tronco, pbx_troncos_sip.portabilidade FROM pbx_troncos_sip UNION ALL SELECT 'IAX2'::text AS tipo, pbx_troncos_iax.id, pbx_troncos_iax.nome, pbx_troncos_iax.max_ligacoes, pbx_troncos_iax.nome AS username, pbx_troncos_iax.contrato, pbx_troncos_iax.callerid, pbx_troncos_iax.context, pbx_troncos_iax.callerid AS callerid_tronco, pbx_troncos_iax.portabilidade FROM pbx_troncos_iax) UNION ALL SELECT 'KHOMP'::text AS tipo, pbx_troncos_khomp.id, pbx_troncos_khomp.descricao AS nome, pbx_troncos_khomp.max_ligacoes, pbx_troncos_khomp.grupo AS username, pbx_troncos_khomp.contrato, pbx_troncos_khomp.callerid, pbx_troncos_khomp.contexto AS context, pbx_troncos_khomp.callerid AS callerid_tronco, pbx_troncos_khomp.portabilidade FROM pbx_troncos_khomp;


ALTER TABLE public.pbx_troncos OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_troncos_dahdi; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_troncos_dahdi (
    id integer DEFAULT nextval('pbx_troncos_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    interface character varying(80),
    max_ligacoes integer,
    canal_dahdi character varying(10),
    framing character varying(80) DEFAULT ''::character varying,
    signalling character varying(80) DEFAULT ''::character varying,
    mfcr2_variant character varying(80) DEFAULT 'br'::character varying,
    timing character varying(80) DEFAULT '0'::character varying,
    lbo character varying(80) DEFAULT ''::character varying,
    spannum character varying(80) DEFAULT ''::character varying,
    coding character varying(80) DEFAULT ''::character varying,
    crc4 character varying(80) DEFAULT ''::character varying,
    mfcr2_get_ani_first character varying(80) DEFAULT ''::character varying,
    mfcr2_max_ani character varying(80) DEFAULT '20'::character varying,
    mfcr2_max_dnis character varying(80) DEFAULT '4'::character varying,
    mfcr2_category character varying(80) DEFAULT ''::character varying,
    mfcr2_allow_collect_calls character varying(80) DEFAULT ''::character varying,
    mfcr2_double_answer character varying(80) DEFAULT ''::character varying,
    echocancel character varying(80) DEFAULT ''::character varying,
    echocancelwhenbridged character varying(80) DEFAULT ''::character varying,
    echotraining character varying(80) DEFAULT 'no'::character varying,
    echocanceller character varying(80) DEFAULT ''::character varying,
    context character varying(80) DEFAULT ''::character varying,
    channel character varying(80) DEFAULT ''::character varying,
    cas character varying(80) DEFAULT ''::character varying,
    dchan character varying(80) DEFAULT ''::character varying,
    "group" character varying(80) DEFAULT ''::character varying,
    txgain character varying(80) DEFAULT ''::character varying,
    rxgain character varying(80) DEFAULT ''::character varying,
    loadzone character varying(80) DEFAULT ''::character varying,
    defaultzone character varying(80) DEFAULT ''::character varying,
    switchtype character varying(80) DEFAULT ''::character varying,
    pridialplan character varying(80) DEFAULT ''::character varying,
    prilocaldialplan character varying(80) DEFAULT ''::character varying,
    overlapdial character varying(80) DEFAULT ''::character varying,
    bchan character varying(80) DEFAULT ''::character varying,
    alaw character varying(80) DEFAULT ''::character varying,
    dynamic_rede character varying(80) DEFAULT ''::character varying,
    dynamic_mac character varying(80) DEFAULT ''::character varying,
    dynamic_span character varying(80) DEFAULT ''::character varying,
    dynamic_canais character varying(80) DEFAULT ''::character varying,
    dynamic_cascata character varying(80) DEFAULT ''::character varying,
    busydetect character varying(80) DEFAULT ''::character varying,
    busycount character varying(80) DEFAULT ''::character varying,
    fxsks character varying(80) DEFAULT ''::character varying,
    callerid character varying(80) DEFAULT ''::character varying,
    cidsignalling character varying(80) DEFAULT ''::character varying,
    cidstart character varying(80) DEFAULT ''::character varying,
    echocanceller_canais character varying(80) DEFAULT ''::character varying,
    contrato integer,
    param_opc text,
    tipo_cadastro character varying(10),
    fxoks character varying(80) DEFAULT ''::character varying,
    sinalizacao_tipo character varying(80),
    dispositivo integer DEFAULT 0,
    channel_1 integer,
    channel_2 integer,
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_troncos_dahdi OWNER TO contacte;

SET default_with_oids = true;

--
-- Name: pbx_troncos_dgv; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_troncos_dgv (
    id integer DEFAULT nextval('pbx_troncos_id_seq'::regclass) NOT NULL,
    nome character varying(100),
    identificador character varying(100),
    max_ligacoes integer,
    canal_dgv character varying(10),
    contrato integer DEFAULT 0 NOT NULL,
    portabilidade integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.pbx_troncos_dgv OWNER TO contacte;

SET default_with_oids = false;

--
-- Name: pbx_turnos; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pbx_turnos (
    id integer DEFAULT nextval(('"public"."pbx_turnos_id_seq"'::text)::regclass) NOT NULL,
    entrada time(0) without time zone NOT NULL,
    saida time(0) without time zone NOT NULL,
    flag integer
);


ALTER TABLE public.pbx_turnos OWNER TO postgres;

--
-- Name: pbx_turnos_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE pbx_turnos_id_seq
    START WITH 1
    INCREMENT BY 1
    MAXVALUE 2147483647
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_turnos_id_seq OWNER TO postgres;

--
-- Name: pbx_uf; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE pbx_uf (
    uf character(2) NOT NULL,
    uf_cod integer,
    uf_descricao character varying(80)
);


ALTER TABLE public.pbx_uf OWNER TO simplesip;

--
-- Name: pbx_ura_anuncio; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_ura_anuncio (
    id_ura integer,
    musica_anuncio character varying(100)
);


ALTER TABLE public.pbx_ura_anuncio OWNER TO contacte;

--
-- Name: pbx_ura_destino_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_ura_destino_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_ura_destino_id_seq OWNER TO contacte;

--
-- Name: pbx_ura_destino; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_ura_destino (
    id integer DEFAULT nextval('pbx_ura_destino_id_seq'::regclass) NOT NULL,
    id_ura integer NOT NULL,
    numero character varying(100),
    tipo character(30),
    comando character varying(100),
    som_ura character varying(100),
    display_comanado character varying(100),
    sequencia integer DEFAULT 0 NOT NULL,
    nome_comando character varying(100),
    visible character varying(1) DEFAULT 'S'::character varying
);


ALTER TABLE public.pbx_ura_destino OWNER TO contacte;

--
-- Name: pbx_ura_movimento; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_ura_movimento (
    umv_id bigint NOT NULL,
    umv_data date DEFAULT (now())::date NOT NULL,
    uniqueid character varying(32),
    umv_tipo character(3) NOT NULL,
    umv_ura_id integer,
    umv_atendimento bigint DEFAULT 0 NOT NULL,
    umv_desc_servico character varying(255),
    umv_ura_opcao character varying(32),
    umv_ult_atend_ura bigint DEFAULT 0 NOT NULL,
    umv_ult_atend_opcao bigint DEFAULT 0 NOT NULL,
    umv_opcao character varying(128),
    umv_acao character varying(128),
    reg_proc character varying(255),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    umv_ura_nome character varying(100)
);


ALTER TABLE public.pbx_ura_movimento OWNER TO contacte;

--
-- Name: pbx_ura_movimento_umv_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_ura_movimento_umv_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_ura_movimento_umv_id_seq OWNER TO contacte;

--
-- Name: pbx_ura_movimento_umv_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_ura_movimento_umv_id_seq OWNED BY pbx_ura_movimento.umv_id;


--
-- Name: pbx_urls_id; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_urls_id
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_urls_id OWNER TO contacte;

--
-- Name: pbx_urls; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_urls (
    id integer DEFAULT nextval('pbx_urls_id'::regclass) NOT NULL,
    tipo character varying(100),
    endereco character varying(500)
);


ALTER TABLE public.pbx_urls OWNER TO contacte;

--
-- Name: pbx_usuarios_cs; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_usuarios_cs AS
    SELECT pbx_cs_usuarios.id, pbx_cs_usuarios.nome, pbx_cs_usuarios.apelido, pbx_cs_usuarios.empresa, pbx_cs_usuarios.departamento, pbx_cs_usuarios.matricula FROM pbx_cs_usuarios WHERE (pbx_cs_usuarios.status = 'A'::bpchar);


ALTER TABLE public.pbx_usuarios_cs OWNER TO contacte;

--
-- Name: pbx_usuarios_dacs; Type: VIEW; Schema: public; Owner: contacte
--

CREATE VIEW pbx_usuarios_dacs AS
    SELECT a.user_id AS id_usuario, c.apelido, c.nome, a.gp_id, d.gp_nome, b.id AS id_dac, e.nome AS nome_dac FROM pbx_grupo_usuario a, pbx_fila_grupos b, pbx_usuarios c, pbx_grupo d, pbx_dacs e WHERE ((((b.gp_id = a.gp_id) AND (c.id = a.user_id)) AND (d.gp_id = a.gp_id)) AND (e.id = b.id));


ALTER TABLE public.pbx_usuarios_dacs OWNER TO contacte;

--
-- Name: pbx_usuarios_senha; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_usuarios_senha (
    id integer NOT NULL,
    id_usuario integer NOT NULL,
    senha character varying(50) NOT NULL,
    data_reg timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_usuarios_senha OWNER TO contacte;

--
-- Name: pbx_usuarios_senha_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_usuarios_senha_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_usuarios_senha_id_seq OWNER TO contacte;

--
-- Name: pbx_usuarios_senha_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_usuarios_senha_id_seq OWNED BY pbx_usuarios_senha.id;


--
-- Name: pbx_voicemail_general; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_voicemail_general (
    attach character varying(3),
    format character varying(100),
    charset character varying(100),
    delete character varying(3),
    emailsubject character varying(100),
    emailbody text,
    serveremail character varying(100),
    fromstring character varying(100),
    mailcmd character varying(100),
    forcegreetings character varying(100),
    forcename character varying(3),
    searchcontexts character varying(3),
    maxmsg integer,
    maxmessage integer,
    minmessage integer,
    maxgreet integer,
    maxsilence integer,
    silencethreshold integer,
    maxlogins integer,
    skipms integer,
    usedirectory character varying(3),
    saycid character varying(3),
    emaildateformat character varying(100),
    zonemessages character varying(100)
);


ALTER TABLE public.pbx_voicemail_general OWNER TO contacte;

--
-- Name: pbx_whatsapp_message; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_whatsapp_message (
    wappmsg_id integer NOT NULL,
    wapp_id character varying(50) NOT NULL,
    wappmsg_nome character varying(200) NOT NULL,
    wappmsg_telefone character varying(50) NOT NULL,
    wappmsg_type character varying(50),
    wappmsg_mime character varying(50),
    wappmsg_body text,
    wappmsg_timestamp timestamp without time zone,
    wappmsg_data timestamp without time zone DEFAULT now()
);


ALTER TABLE public.pbx_whatsapp_message OWNER TO contacte;

--
-- Name: pbx_whatsapp_message_wappmsg_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_whatsapp_message_wappmsg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_whatsapp_message_wappmsg_id_seq OWNER TO contacte;

--
-- Name: pbx_whatsapp_message_wappmsg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_whatsapp_message_wappmsg_id_seq OWNED BY pbx_whatsapp_message.wappmsg_id;


--
-- Name: pbx_whatsapp_send; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_whatsapp_send (
    wapp_id integer NOT NULL,
    wapp_telefone character varying(50) NOT NULL,
    wapp_matricula character varying(10) NOT NULL,
    wapp_tipo character varying(1) NOT NULL,
    wapp_status character varying(1) DEFAULT 1,
    wapp_data timestamp without time zone DEFAULT now(),
    wapp_ini timestamp without time zone DEFAULT now(),
    wapp_fim timestamp without time zone
);


ALTER TABLE public.pbx_whatsapp_send OWNER TO contacte;

--
-- Name: pbx_whatsapp_send_wapp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_whatsapp_send_wapp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_whatsapp_send_wapp_id_seq OWNER TO contacte;

--
-- Name: pbx_whatsapp_send_wapp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_whatsapp_send_wapp_id_seq OWNED BY pbx_whatsapp_send.wapp_id;


--
-- Name: pbx_workflow_emails; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_workflow_emails (
    wkf_email_id integer NOT NULL,
    wkf_email character varying(80) NOT NULL,
    wkf_tipo_envio integer DEFAULT 1 NOT NULL,
    wkf_status integer DEFAULT 1 NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    wkf_nome character varying(80)
);


ALTER TABLE public.pbx_workflow_emails OWNER TO contacte;

--
-- Name: pbx_workflow_emails_dacs; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_workflow_emails_dacs (
    wkf_email_id integer NOT NULL,
    nome_dac character varying(100) NOT NULL
);


ALTER TABLE public.pbx_workflow_emails_dacs OWNER TO contacte;

--
-- Name: pbx_workflow_emails_wkf_email_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_workflow_emails_wkf_email_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_workflow_emails_wkf_email_id_seq OWNER TO contacte;

--
-- Name: pbx_workflow_emails_wkf_email_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_workflow_emails_wkf_email_id_seq OWNED BY pbx_workflow_emails.wkf_email_id;


--
-- Name: pbx_workflow_parametros; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_workflow_parametros (
    wkf_id integer NOT NULL,
    wkf_status_servico integer DEFAULT 1 NOT NULL,
    wkf_hora_envio integer DEFAULT 6 NOT NULL,
    wkf_minuto_envio integer DEFAULT 0 NOT NULL,
    wkf_smtp character varying(100),
    wkf_smtp_user character varying(50),
    wkf_smtp_senha character varying(255),
    wkf_smtp_port character varying(11),
    wkf_smtp_requer_aut integer DEFAULT 0 NOT NULL,
    wkf_logo_parceiro character varying(255) DEFAULT 'logoParceiro.png'::character varying NOT NULL
);


ALTER TABLE public.pbx_workflow_parametros OWNER TO contacte;

--
-- Name: pbx_workflow_reg_envio; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_workflow_reg_envio (
    wkf_data_envio date NOT NULL,
    wkf_data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_workflow_reg_envio OWNER TO contacte;

--
-- Name: pbx_workflow_reg_envio_email; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_workflow_reg_envio_email (
    wkf_id integer NOT NULL,
    wkf_data_envio date NOT NULL,
    wkf_email character varying(80) NOT NULL,
    wkf_status integer,
    wkf_msg character varying(1024),
    wkf_data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_workflow_reg_envio_email OWNER TO contacte;

--
-- Name: pbx_workflow_reg_envio_email_mensal; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_workflow_reg_envio_email_mensal (
    wkf_id integer NOT NULL,
    wkf_data_envio character varying(6) NOT NULL,
    wkf_email character varying(80) NOT NULL,
    wkf_status integer,
    wkf_msg character varying(1024),
    wkf_data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_workflow_reg_envio_email_mensal OWNER TO contacte;

--
-- Name: pbx_workflow_reg_envio_email_mensal_wkf_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_workflow_reg_envio_email_mensal_wkf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_workflow_reg_envio_email_mensal_wkf_id_seq OWNER TO contacte;

--
-- Name: pbx_workflow_reg_envio_email_mensal_wkf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_workflow_reg_envio_email_mensal_wkf_id_seq OWNED BY pbx_workflow_reg_envio_email_mensal.wkf_id;


--
-- Name: pbx_workflow_reg_envio_email_wkf_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE pbx_workflow_reg_envio_email_wkf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.pbx_workflow_reg_envio_email_wkf_id_seq OWNER TO contacte;

--
-- Name: pbx_workflow_reg_envio_email_wkf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE pbx_workflow_reg_envio_email_wkf_id_seq OWNED BY pbx_workflow_reg_envio_email.wkf_id;


--
-- Name: pbx_workflow_reg_envio_mensal; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE pbx_workflow_reg_envio_mensal (
    wkf_data_envio character varying(6) NOT NULL,
    wkf_data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pbx_workflow_reg_envio_mensal OWNER TO contacte;

--
-- Name: piperun; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE piperun (
    id_piperun integer NOT NULL,
    calldate_piperun timestamp without time zone DEFAULT now(),
    src_piperun character varying(20) NOT NULL,
    dst_piperun character varying(25) NOT NULL,
    user_piperun character varying(20) NOT NULL,
    id_crm_call character varying(30) NOT NULL,
    status_call integer NOT NULL,
    update_at timestamp without time zone DEFAULT now(),
    send_return_piperun boolean DEFAULT false,
    uniqueid_piperun character varying(200)
);


ALTER TABLE public.piperun OWNER TO contacte;

--
-- Name: piperun_id_piperun_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE piperun_id_piperun_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.piperun_id_piperun_seq OWNER TO contacte;

--
-- Name: piperun_id_piperun_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE piperun_id_piperun_seq OWNED BY piperun.id_piperun;


--
-- Name: portabilidade; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE portabilidade (
    tel_doadora bigint,
    spid integer
);


ALTER TABLE public.portabilidade OWNER TO contacte;

--
-- Name: prefixos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE prefixos (
    spid integer NOT NULL,
    prefixo integer NOT NULL,
    ini integer NOT NULL,
    fim integer NOT NULL
);


ALTER TABLE public.prefixos OWNER TO contacte;

--
-- Name: prefixos_teste_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE prefixos_teste_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.prefixos_teste_id_seq OWNER TO contacte;

--
-- Name: rma_departamentos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE rma_departamentos (
    dpto_id integer NOT NULL,
    dpto_nome character varying(120) NOT NULL,
    dpto_status integer DEFAULT 1 NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    user_reg integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.rma_departamentos OWNER TO contacte;

--
-- Name: rma_departamentos_dpto_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE rma_departamentos_dpto_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.rma_departamentos_dpto_id_seq OWNER TO contacte;

--
-- Name: rma_departamentos_dpto_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE rma_departamentos_dpto_id_seq OWNED BY rma_departamentos.dpto_id;


--
-- Name: rma_depto_ramais; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE rma_depto_ramais (
    nome character varying(100) NOT NULL,
    dpto_id integer NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rma_depto_ramais OWNER TO contacte;

--
-- Name: sip_dif_versao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE sip_dif_versao (
    dif_id bigint NOT NULL,
    varq_file_name character varying(255),
    varq_file_pah character varying(1024)
);


ALTER TABLE public.sip_dif_versao OWNER TO contacte;

--
-- Name: sip_dif_versao_dif_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE sip_dif_versao_dif_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.sip_dif_versao_dif_id_seq OWNER TO contacte;

--
-- Name: sip_dif_versao_dif_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE sip_dif_versao_dif_id_seq OWNED BY sip_dif_versao.dif_id;


--
-- Name: sip_versao; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE sip_versao (
    ver_id integer NOT NULL,
    ver_number character varying(64) NOT NULL,
    ver_descricao character varying(255),
    ver_data_lancamento date,
    ver_data_suporte date,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.sip_versao OWNER TO contacte;

--
-- Name: sip_versao_arquivos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE sip_versao_arquivos (
    varq_id integer NOT NULL,
    ver_number character varying(64) NOT NULL,
    varq_ext character varying(32),
    varq_file_name character varying(255),
    varq_file_pah character varying(1024),
    varq_relative_path character varying(1024),
    varq_size integer,
    varq_md5_name character varying(32),
    varq_md5_file character varying(32),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.sip_versao_arquivos OWNER TO contacte;

--
-- Name: sip_versao_arquivos_varq_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE sip_versao_arquivos_varq_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.sip_versao_arquivos_varq_id_seq OWNER TO contacte;

--
-- Name: sip_versao_arquivos_varq_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE sip_versao_arquivos_varq_id_seq OWNED BY sip_versao_arquivos.varq_id;


--
-- Name: sip_versao_ver_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE sip_versao_ver_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.sip_versao_ver_id_seq OWNER TO contacte;

--
-- Name: sip_versao_ver_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE sip_versao_ver_id_seq OWNED BY sip_versao.ver_id;


--
-- Name: tb_lista_discador; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE tb_lista_discador (
    numero character varying(32),
    nome character varying(255),
    codigo character varying(50),
    data character varying(50),
    ld_id integer
);


ALTER TABLE public.tb_lista_discador OWNER TO contacte;

--
-- Name: tmp_modelos_incluidos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE tmp_modelos_incluidos (
    id integer NOT NULL,
    id_session character varying(100),
    id_modelo character varying(100),
    nome_modelo character varying(100),
    recorte character varying(10),
    acrescenta character varying(10),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tmp_modelos_incluidos OWNER TO contacte;

--
-- Name: tmp_modelos_incluidos_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE tmp_modelos_incluidos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tmp_modelos_incluidos_id_seq OWNER TO contacte;

--
-- Name: tmp_modelos_incluidos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE tmp_modelos_incluidos_id_seq OWNED BY tmp_modelos_incluidos.id;


--
-- Name: tmp_troncos_incluidos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE tmp_troncos_incluidos (
    id integer NOT NULL,
    id_session character varying(100),
    id_modelo character varying(100),
    nome_modelo character varying(100),
    id_tronco integer,
    nome_tronco character varying(100),
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tmp_troncos_incluidos OWNER TO contacte;

--
-- Name: tmp_troncos_incluidos_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE tmp_troncos_incluidos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tmp_troncos_incluidos_id_seq OWNER TO contacte;

--
-- Name: tmp_troncos_incluidos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE tmp_troncos_incluidos_id_seq OWNED BY tmp_troncos_incluidos.id;


--
-- Name: vds_acompanha; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_acompanha (
    acp_id bigint NOT NULL,
    emp_id integer NOT NULL,
    acp_tipo_integracao character varying(32),
    acp_integrado_cloud integer,
    acp_integrado_cli integer,
    acp_data_cloud timestamp without time zone DEFAULT now() NOT NULL,
    acp_data_cli timestamp without time zone,
    acp_verificado integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.vds_acompanha OWNER TO contacte;

--
-- Name: vds_acompanha_acp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_acompanha_acp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_acompanha_acp_id_seq OWNER TO contacte;

--
-- Name: vds_acompanha_acp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_acompanha_acp_id_seq OWNED BY vds_acompanha.acp_id;


--
-- Name: vds_api_encotrado; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_api_encotrado (
    id_nec integer NOT NULL,
    proto character varying(64),
    tipo character(1) DEFAULT 'I'::bpchar NOT NULL,
    proc integer DEFAULT 0 NOT NULL,
    data date DEFAULT (now())::date NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vds_api_encotrado OWNER TO contacte;

--
-- Name: vds_api_encotrado_id_nec_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_api_encotrado_id_nec_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_api_encotrado_id_nec_seq OWNER TO contacte;

--
-- Name: vds_api_encotrado_id_nec_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_api_encotrado_id_nec_seq OWNED BY vds_api_encotrado.id_nec;


--
-- Name: vds_api_nao_encotrado; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_api_nao_encotrado (
    id_nec integer NOT NULL,
    proto character varying(64),
    tipo character(1) DEFAULT 'I'::bpchar NOT NULL,
    proc integer DEFAULT 0 NOT NULL,
    data date DEFAULT (now())::date NOT NULL,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vds_api_nao_encotrado OWNER TO contacte;

--
-- Name: vds_api_nao_encotrado_id_nec_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_api_nao_encotrado_id_nec_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_api_nao_encotrado_id_nec_seq OWNER TO contacte;

--
-- Name: vds_api_nao_encotrado_id_nec_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_api_nao_encotrado_id_nec_seq OWNED BY vds_api_nao_encotrado.id_nec;


--
-- Name: vds_chamadas; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_chamadas (
    chm_id bigint NOT NULL,
    emp_id integer NOT NULL,
    uid character varying(32) NOT NULL,
    chm_data_bilhete date NOT NULL,
    chm_calldate timestamp without time zone NOT NULL,
    chm_src character varying(128),
    chm_dst character varying(128),
    chm_duration bigint,
    chm_billsec bigint,
    chm_userfield character varying(256),
    chm_fila character varying(128),
    chm_matricula character varying(32),
    chm_evento character varying(128)
);


ALTER TABLE public.vds_chamadas OWNER TO contacte;

--
-- Name: vds_chamadas_chm_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_chamadas_chm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_chamadas_chm_id_seq OWNER TO contacte;

--
-- Name: vds_chamadas_chm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_chamadas_chm_id_seq OWNED BY vds_chamadas.chm_id;


--
-- Name: vds_chamadas_confere; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE vds_chamadas_confere (
    emp_id integer NOT NULL,
    cfr_data date NOT NULL,
    cfr_fila character varying(128) NOT NULL,
    cfr_numero_chamadas integer,
    cfr_numero_chamadas_local integer,
    cfr_processada integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.vds_chamadas_confere OWNER TO postgres;

--
-- Name: vds_chamadas_diario; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_chamadas_diario (
    id_chm_diario integer NOT NULL,
    id_pk_emp integer NOT NULL,
    originadas bigint,
    atendidas bigint,
    vendido bigint,
    nao_atendidas bigint,
    data_ini date NOT NULL,
    data_fim date NOT NULL
);


ALTER TABLE public.vds_chamadas_diario OWNER TO contacte;

--
-- Name: vds_chamadas_diario_id_chm_diario_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_chamadas_diario_id_chm_diario_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_chamadas_diario_id_chm_diario_seq OWNER TO contacte;

--
-- Name: vds_chamadas_diario_id_chm_diario_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_chamadas_diario_id_chm_diario_seq OWNED BY vds_chamadas_diario.id_chm_diario;


--
-- Name: vds_classificacoes; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_classificacoes (
    clas_id bigint NOT NULL,
    emp_id integer NOT NULL,
    uid character varying(32),
    clas_matricula character varying(32),
    clas_descricao character varying(128),
    clas_descricao_item character varying(128),
    clas_reg timestamp without time zone,
    clas_dac character varying(64),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    clas_data date
);


ALTER TABLE public.vds_classificacoes OWNER TO contacte;

--
-- Name: vds_classificacoes_clas_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_classificacoes_clas_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_classificacoes_clas_id_seq OWNER TO contacte;

--
-- Name: vds_classificacoes_clas_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_classificacoes_clas_id_seq OWNED BY vds_classificacoes.clas_id;


--
-- Name: vds_classificacoes_confere; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE vds_classificacoes_confere (
    emp_id integer NOT NULL,
    cfr_data date NOT NULL,
    cfr_fila character varying(128) NOT NULL,
    cfr_numero_classificacoes integer,
    cfr_numero_classificacoes_local integer,
    cfr_processada integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.vds_classificacoes_confere OWNER TO postgres;

--
-- Name: vds_empresas; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_empresas (
    emp_id integer NOT NULL,
    emp_cnpj character varying(32) NOT NULL,
    emp_ie character varying(32) DEFAULT 'ISENTO'::character varying NOT NULL,
    emp_razao_social character varying(128),
    emp_nome_fantasia character varying(128),
    emp_municipio character varying(128) NOT NULL,
    emp_uf character(2) NOT NULL,
    emp_contato character varying(64),
    emp_fone character varying(32),
    user_reg integer,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    emp_vpn character varying(15),
    emp_diretorio_ftp character varying(50),
    emp_cloud integer DEFAULT 0 NOT NULL,
    emp_cloud_filas text,
    emp_reproc integer DEFAULT 0 NOT NULL,
    emp_status integer DEFAULT 0,
    emp_ult_atualizacao timestamp without time zone,
    emp_ddd integer
);


ALTER TABLE public.vds_empresas OWNER TO contacte;

--
-- Name: vds_grupos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_grupos (
    grp_id integer NOT NULL,
    grp_nome character varying(64) NOT NULL,
    gpr_status integer DEFAULT 0 NOT NULL,
    user_reg integer,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vds_grupos OWNER TO contacte;

--
-- Name: vds_grupos_empresas; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_grupos_empresas (
    grp_id integer NOT NULL,
    emp_id integer NOT NULL
);


ALTER TABLE public.vds_grupos_empresas OWNER TO contacte;

--
-- Name: vds_grupos_grp_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_grupos_grp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_grupos_grp_id_seq OWNER TO contacte;

--
-- Name: vds_grupos_grp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_grupos_grp_id_seq OWNED BY vds_grupos.grp_id;


--
-- Name: vds_log; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_log (
    log_id bigint NOT NULL,
    emp_id integer,
    log_data date DEFAULT (now())::date NOT NULL,
    log_ip_client character varying(64),
    log_type character varying(10) DEFAULT 'ERRO'::character varying NOT NULL,
    log_mensagem text,
    log_file text,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vds_log OWNER TO contacte;

--
-- Name: vds_log_log_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_log_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_log_log_id_seq OWNER TO contacte;

--
-- Name: vds_log_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_log_log_id_seq OWNED BY vds_log.log_id;


--
-- Name: vds_pesquisa_log; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_pesquisa_log (
    plog_id bigint NOT NULL,
    emp_id integer NOT NULL,
    plog_data date DEFAULT (now())::date NOT NULL,
    uniqueid character varying(32) NOT NULL,
    matricula character varying(10),
    plog_log text,
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    id_dac integer NOT NULL,
    fila character varying(128) NOT NULL,
    pl_id integer NOT NULL,
    integra_vendas integer DEFAULT 0
);


ALTER TABLE public.vds_pesquisa_log OWNER TO contacte;

--
-- Name: vds_pesquisa_log_plog_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_pesquisa_log_plog_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_pesquisa_log_plog_id_seq OWNER TO contacte;

--
-- Name: vds_pesquisa_log_plog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_pesquisa_log_plog_id_seq OWNED BY vds_pesquisa_log.plog_id;


--
-- Name: vds_pesquisa_regitra; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_pesquisa_regitra (
    uniqueid character varying(32) NOT NULL,
    emp_codigo integer,
    id_dac integer,
    matricula character varying(10),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    data_fim timestamp without time zone
);


ALTER TABLE public.vds_pesquisa_regitra OWNER TO contacte;

--
-- Name: vds_protcolos; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_protcolos (
    prt_id bigint NOT NULL,
    emp_id integer NOT NULL,
    uid character varying(32) NOT NULL,
    prt_ano integer,
    prt_numproto integer,
    prt_protocolo bigint,
    prt_proto_parceiro character varying(64),
    data_reg timestamp without time zone DEFAULT now() NOT NULL,
    data_protocolo timestamp without time zone,
    id_unk integer NOT NULL
);


ALTER TABLE public.vds_protcolos OWNER TO contacte;

--
-- Name: vds_protcolos_id_unk_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_protcolos_id_unk_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_protcolos_id_unk_seq OWNER TO contacte;

--
-- Name: vds_protcolos_id_unk_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_protcolos_id_unk_seq OWNED BY vds_protcolos.id_unk;


--
-- Name: vds_protcolos_prt_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_protcolos_prt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_protcolos_prt_id_seq OWNER TO contacte;

--
-- Name: vds_protcolos_prt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_protcolos_prt_id_seq OWNED BY vds_protcolos.prt_id;


--
-- Name: vds_protocolos_confere; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE vds_protocolos_confere (
    emp_id integer NOT NULL,
    cfr_data date NOT NULL,
    cfr_numero_protocolos integer,
    cfr_numero_protocolos_local integer,
    cfr_processada integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.vds_protocolos_confere OWNER TO postgres;

--
-- Name: vds_usuarios_confere; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE vds_usuarios_confere (
    emp_id integer NOT NULL,
    cfr_matricula character varying(16) NOT NULL,
    cfr_processada integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.vds_usuarios_confere OWNER TO postgres;

--
-- Name: vds_vendedores; Type: TABLE; Schema: public; Owner: contacte; Tablespace: 
--

CREATE TABLE vds_vendedores (
    vdr_id integer NOT NULL,
    emp_id integer NOT NULL,
    vdr_nome character varying(128) NOT NULL,
    vdr_apelido character varying(32),
    vdr_matricula character varying(16) NOT NULL,
    vdr_email character varying(64),
    user_reg integer,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vds_vendedores OWNER TO contacte;

--
-- Name: vds_vendedores_vdr_id_seq; Type: SEQUENCE; Schema: public; Owner: contacte
--

CREATE SEQUENCE vds_vendedores_vdr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vds_vendedores_vdr_id_seq OWNER TO contacte;

--
-- Name: vds_vendedores_vdr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: contacte
--

ALTER SEQUENCE vds_vendedores_vdr_id_seq OWNED BY vds_vendedores.vdr_id;


--
-- Name: vph_contato_agenda; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE vph_contato_agenda (
    id_contato character varying(50) NOT NULL,
    nome character varying(70) NOT NULL,
    sobrenome character varying(100),
    foto text,
    ramal character varying(20) NOT NULL,
    email character varying(80),
    endereco character varying(120),
    celular character varying(18),
    telefone character varying(18),
    empresa character varying(80),
    status character varying(10),
    data_upd timestamp without time zone,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vph_contato_agenda OWNER TO simplesip;

--
-- Name: vph_grupo_agenda; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE vph_grupo_agenda (
    id_grupo integer NOT NULL,
    descricao character varying(40) NOT NULL
);


ALTER TABLE public.vph_grupo_agenda OWNER TO simplesip;

--
-- Name: vph_grupo_agenda_id_grupo_seq; Type: SEQUENCE; Schema: public; Owner: simplesip
--

CREATE SEQUENCE vph_grupo_agenda_id_grupo_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.vph_grupo_agenda_id_grupo_seq OWNER TO simplesip;

--
-- Name: vph_grupo_agenda_id_grupo_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: simplesip
--

ALTER SEQUENCE vph_grupo_agenda_id_grupo_seq OWNED BY vph_grupo_agenda.id_grupo;


--
-- Name: vph_itens_contato; Type: TABLE; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE TABLE vph_itens_contato (
    id_itcontato character varying(50) NOT NULL,
    id_contato character varying(50) NOT NULL,
    descricao character varying(80) NOT NULL,
    nome_grupo character varying(80),
    status character varying(10),
    data_upd timestamp without time zone,
    data_reg timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vph_itens_contato OWNER TO simplesip;

--
-- Name: id_bilhetes; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ast_bilhetes ALTER COLUMN id_bilhetes SET DEFAULT nextval('ast_bilhetes_id_bilhetes_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY ast_bilhetes_complemento ALTER COLUMN id SET DEFAULT nextval('ast_bilhetes_complemento_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY ast_eventos_dacs ALTER COLUMN id SET DEFAULT nextval('ast_eventos_dacs_id_seq'::regclass);


--
-- Name: id_rout; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY atualiza_routing ALTER COLUMN id_rout SET DEFAULT nextval('atualiza_routing_id_rout_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY cdr ALTER COLUMN id SET DEFAULT nextval('cdr_id_seq'::regclass);


--
-- Name: scm_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY mkt_dados_anatel_scm ALTER COLUMN scm_id SET DEFAULT nextval('mkt_dados_anatel_scm_scm_id_seq'::regclass);


--
-- Name: mkt_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY mkt_prospect ALTER COLUMN mkt_id SET DEFAULT nextval('mkt_prospect_mkt_id_seq'::regclass);


--
-- Name: id_servidor; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_agenda_servidores ALTER COLUMN id_servidor SET DEFAULT nextval('pbx_agenda_servidores_id_servidor_seq'::regclass);


--
-- Name: arq_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_arquivo_som ALTER COLUMN arq_id SET DEFAULT nextval('pbx_arquivo_som_arq_id_seq'::regclass);


--
-- Name: aud_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_audita ALTER COLUMN aud_id SET DEFAULT nextval('pbx_audita_aud_id_seq'::regclass);


--
-- Name: full_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_audita_full ALTER COLUMN full_id SET DEFAULT nextval('pbx_audita_full_full_id_seq'::regclass);


--
-- Name: bkp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup ALTER COLUMN bkp_id SET DEFAULT nextval('pbx_backup_bkp_id_seq'::regclass);


--
-- Name: arq_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_arquivos ALTER COLUMN arq_id SET DEFAULT nextval('pbx_backup_arquivos_arq_id_seq'::regclass);


--
-- Name: cfg_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_configuracao ALTER COLUMN cfg_id SET DEFAULT nextval('pbx_backup_configuracao_cfg_id_seq'::regclass);


--
-- Name: dst_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_destino ALTER COLUMN dst_id SET DEFAULT nextval('pbx_backup_destino_dst_id_seq'::regclass);


--
-- Name: id_bilhetes; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_bilhetes_wpp ALTER COLUMN id_bilhetes SET DEFAULT nextval('pbx_bilhetes_wpp_id_bilhetes_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cadastro_funcoes ALTER COLUMN id SET DEFAULT nextval('pbx_cadastro_funcoes_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_callback ALTER COLUMN id SET DEFAULT nextval('pbx_callback_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_callback_numeros ALTER COLUMN id SET DEFAULT nextval('pbx_callback_numeros_id_seq'::regclass);


--
-- Name: cmp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha ALTER COLUMN cmp_id SET DEFAULT nextval('pbx_campanha_cmp_id_seq'::regclass);


--
-- Name: cont_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_contato ALTER COLUMN cont_id SET DEFAULT nextval('pbx_campanha_contato_cont_id_seq'::regclass);


--
-- Name: disp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_contato_display ALTER COLUMN disp_id SET DEFAULT nextval('pbx_campanha_contato_display_disp_id_seq'::regclass);


--
-- Name: conf_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_contato_fone ALTER COLUMN conf_id SET DEFAULT nextval('pbx_campanha_contato_fone_conf_id_seq'::regclass);


--
-- Name: list_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_lista ALTER COLUMN list_id SET DEFAULT nextval('pbx_campanha_lista_list_id_seq'::regclass);


--
-- Name: cmpo_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_operacao ALTER COLUMN cmpo_id SET DEFAULT nextval('pbx_campanha_operacao_cmpo_id_seq'::regclass);


--
-- Name: id_param; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_parametros ALTER COLUMN id_param SET DEFAULT nextval('pbx_campanha_parametros_id_param_seq'::regclass);


--
-- Name: id_cmpr; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_registro ALTER COLUMN id_cmpr SET DEFAULT nextval('pbx_campanha_registro_id_cmpr_seq'::regclass);


--
-- Name: id_tpl; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_template ALTER COLUMN id_tpl SET DEFAULT nextval('pbx_campanha_template_id_tpl_seq'::regclass);


--
-- Name: ctp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_tipo ALTER COLUMN ctp_id SET DEFAULT nextval('pbx_campanha_tipo_ctp_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cel ALTER COLUMN id SET DEFAULT nextval('pbx_cel_id_seq'::regclass);


--
-- Name: chdr_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_chamada_ramal ALTER COLUMN chdr_id SET DEFAULT nextval('pbx_chamada_ramal_chdr_id_seq'::regclass);


--
-- Name: client_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente ALTER COLUMN client_id SET DEFAULT nextval('pbx_cliente_client_id_seq'::regclass);


--
-- Name: cla_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_anotacoes ALTER COLUMN cla_id SET DEFAULT nextval('pbx_cliente_anotacoes_cla_id_seq'::regclass);


--
-- Name: clau_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_audio ALTER COLUMN clau_id SET DEFAULT nextval('pbx_cliente_audio_clau_id_seq'::regclass);


--
-- Name: clc_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_contato ALTER COLUMN clc_id SET DEFAULT nextval('pbx_cliente_contato_clc_id_seq'::regclass);


--
-- Name: cfr_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_fornecedor ALTER COLUMN cfr_id SET DEFAULT nextval('pbx_cliente_fornecedor_cfr_id_seq'::regclass);


--
-- Name: clo_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_origem ALTER COLUMN clo_id SET DEFAULT nextval('pbx_cliente_origem_clo_id_seq'::regclass);


--
-- Name: id_ref_vendedor; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_referencia_vendedor ALTER COLUMN id_ref_vendedor SET DEFAULT nextval('pbx_cliente_referencia_vendedor_id_ref_vendedor_seq'::regclass);


--
-- Name: csg_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_segmento ALTER COLUMN csg_id SET DEFAULT nextval('pbx_cliente_segmento_csg_id_seq'::regclass);


--
-- Name: id_conf; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_conf_padrao ALTER COLUMN id_conf SET DEFAULT nextval('pbx_conf_padrao_id_conf_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_contextos_canais ALTER COLUMN id SET DEFAULT nextval('pbx_contextos_canais_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_contextos_canais_tmp ALTER COLUMN id SET DEFAULT nextval('pbx_contextos_canais_tmp_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_contextos_modelos ALTER COLUMN id SET DEFAULT nextval('pbx_contextos_modelos_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_contextos_modelos_tmp ALTER COLUMN id SET DEFAULT nextval('pbx_contextos_modelos_tmp_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_contextos_opcoes ALTER COLUMN id SET DEFAULT nextval('pbx_contextos_opcoes_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_contextos_opcoes_tmp ALTER COLUMN id SET DEFAULT nextval('pbx_contextos_opcoes_tmp_id_seq'::regclass);


--
-- Name: acs_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_controle_acesso ALTER COLUMN acs_id SET DEFAULT nextval('pbx_controle_acesso_acs_id_seq'::regclass);


--
-- Name: acsi_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_controle_acesso_item ALTER COLUMN acsi_id SET DEFAULT nextval('pbx_controle_acesso_item_acsi_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: simplesip
--

ALTER TABLE ONLY pbx_dahdi ALTER COLUMN id SET DEFAULT nextval('pbx_dahdi_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_eventos_agentes_wpp ALTER COLUMN id SET DEFAULT nextval('pbx_eventos_agentes_wpp_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_eventos_dacs_wpp ALTER COLUMN id SET DEFAULT nextval('pbx_eventos_dacs_wpp_id_seq'::regclass);


--
-- Name: trbd_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_eventos_transbordo ALTER COLUMN trbd_id SET DEFAULT nextval('pbx_eventos_transbordo_trbd_id_seq'::regclass);


--
-- Name: id_cfr_permissao; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_fornecedor_permissao ALTER COLUMN id_cfr_permissao SET DEFAULT nextval('pbx_fornecedor_permissao_id_cfr_permissao_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_grupo_ura_ramal ALTER COLUMN id SET DEFAULT nextval('pbx_grupo_ura_ramal_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_horarios ALTER COLUMN id SET DEFAULT nextval('pbx_horarios_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_horarios_itens ALTER COLUMN id SET DEFAULT nextval('pbx_horarios_itens_id_seq'::regclass);


--
-- Name: id_itgc; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_agente_ativo ALTER COLUMN id_itgc SET DEFAULT nextval('pbx_integracao_agente_ativo_id_itgc_seq'::regclass);


--
-- Name: itgc_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_configuracao ALTER COLUMN itgc_id SET DEFAULT nextval('pbx_integracao_configuracao_itgc_id_seq'::regclass);


--
-- Name: itgm_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_metodo ALTER COLUMN itgm_id SET DEFAULT nextval('pbx_integracao_metodo_itgm_id_seq'::regclass);


--
-- Name: reg_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_reg ALTER COLUMN reg_id SET DEFAULT nextval('pbx_integracao_reg_reg_id_seq'::regclass);


--
-- Name: itgt_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_tipo ALTER COLUMN itgt_id SET DEFAULT nextval('pbx_integracao_tipo_itgt_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_khomp ALTER COLUMN id SET DEFAULT nextval('pbx_khomp_id_seq'::regclass);


--
-- Name: id_bloq; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_kingdialer_bloqueios ALTER COLUMN id_bloq SET DEFAULT nextval('pbx_kingdialer_bloqueios_id_bloq_seq'::regclass);


--
-- Name: id_camp_king; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_kingdialer_campanha ALTER COLUMN id_camp_king SET DEFAULT nextval('pbx_kingdialer_campanha_id_camp_king_seq'::regclass);


--
-- Name: id_king; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_kingdialer_config ALTER COLUMN id_king SET DEFAULT nextval('pbx_kingdialer_config_id_king_seq'::regclass);


--
-- Name: id_ligueme_gratis; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_ligueme_gratis ALTER COLUMN id_ligueme_gratis SET DEFAULT nextval('pbx_ligueme_gratis_id_ligueme_gratis_seq'::regclass);


--
-- Name: ld_id; Type: DEFAULT; Schema: public; Owner: simplesip
--

ALTER TABLE ONLY pbx_lista_discador ALTER COLUMN ld_id SET DEFAULT nextval('pbx_lista_discador_ld_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_lista_negra_palavras ALTER COLUMN id SET DEFAULT nextval('pbx_lista_negra_palavras_id_seq'::regclass);


--
-- Name: log_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_log_forms ALTER COLUMN log_id SET DEFAULT nextval('pbx_log_forms_log_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_message_wpp ALTER COLUMN id SET DEFAULT nextval('pbx_message_wpp_id_seq'::regclass);


--
-- Name: m_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_monitora_abdagi ALTER COLUMN m_id SET DEFAULT nextval('pbx_monitora_abdagi_m_id_seq'::regclass);


--
-- Name: mun_id; Type: DEFAULT; Schema: public; Owner: simplesip
--

ALTER TABLE ONLY pbx_municipio_classifica ALTER COLUMN mun_id SET DEFAULT nextval('pbx_municipio_classifica_mun_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: simplesip
--

ALTER TABLE ONLY pbx_municipios ALTER COLUMN id SET DEFAULT nextval('pbx_municipios_id_seq'::regclass);


--
-- Name: npc_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_nao_perturbe_cliente ALTER COLUMN npc_id SET DEFAULT nextval('pbx_nao_perturbe_cliente_npc_id_seq'::regclass);


--
-- Name: np_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_nao_perturbe_controle ALTER COLUMN np_id SET DEFAULT nextval('pbx_nao_perturbe_controle_np_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_normaliza_agenda ALTER COLUMN id SET DEFAULT nextval('pbx_normaliza_agenda_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_notifica_media ALTER COLUMN id SET DEFAULT nextval('pbx_notifica_media_id_seq'::regclass);


--
-- Name: oper_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_operadoras ALTER COLUMN oper_id SET DEFAULT nextval('pbx_operadoras_oper_id_seq'::regclass);


--
-- Name: pp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_pesquisa ALTER COLUMN pp_id SET DEFAULT nextval('pbx_pesquisa_pp_id_seq'::regclass);


--
-- Name: pl_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_pesquisa_liberacao ALTER COLUMN pl_id SET DEFAULT nextval('pbx_pesquisa_liberacao_pl_id_seq'::regclass);


--
-- Name: plog_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_pesquisa_log ALTER COLUMN plog_id SET DEFAULT nextval('pbx_pesquisa_log_plog_id_seq'::regclass);


--
-- Name: pm_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_pesquisa_movimento ALTER COLUMN pm_id SET DEFAULT nextval('pbx_pesquisa_movimento_pm_id_seq'::regclass);


--
-- Name: po_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_pesquisa_opcoes ALTER COLUMN po_id SET DEFAULT nextval('pbx_pesquisa_opcoes_po_id_seq'::regclass);


--
-- Name: pq_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_pesquisa_questoes ALTER COLUMN pq_id SET DEFAULT nextval('pbx_pesquisa_questoes_pq_id_seq'::regclass);


--
-- Name: prm_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_prepago_movimento ALTER COLUMN prm_id SET DEFAULT nextval('pbx_prepago_movimento_prm_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_ramais_pbx ALTER COLUMN id SET DEFAULT nextval('pbx_ramais_pbx_id_seq'::regclass);


--
-- Name: ord_id; Type: DEFAULT; Schema: public; Owner: simplesip
--

ALTER TABLE ONLY pbx_relatorio_ordena ALTER COLUMN ord_id SET DEFAULT nextval('pbx_relatorio_ordena_ord_id_seq'::regclass);


--
-- Name: rpl_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_replica ALTER COLUMN rpl_id SET DEFAULT nextval('pbx_replica_rpl_id_seq'::regclass);


--
-- Name: sms_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_sms_send ALTER COLUMN sms_id SET DEFAULT nextval('pbx_sms_send_sms_id_seq'::regclass);


--
-- Name: idddd; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tab_ddd ALTER COLUMN idddd SET DEFAULT nextval('pbx_tab_ddd_idddd_seq'::regclass);


--
-- Name: contr_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_contrato ALTER COLUMN contr_id SET DEFAULT nextval('pbx_tarif_contrato_contr_id_seq'::regclass);


--
-- Name: prc_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_contrato_preco ALTER COLUMN prc_id SET DEFAULT nextval('pbx_tarif_contrato_preco_prc_id_seq'::regclass);


--
-- Name: tfm_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_franquia_movimento ALTER COLUMN tfm_id SET DEFAULT nextval('pbx_tarif_franquia_movimento_tfm_id_seq'::regclass);


--
-- Name: trr_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_registra ALTER COLUMN trr_id SET DEFAULT nextval('pbx_tarif_registra_trr_id_seq'::regclass);


--
-- Name: trf_id; Type: DEFAULT; Schema: public; Owner: simplesip
--

ALTER TABLE ONLY pbx_tarifador_log ALTER COLUMN trf_id SET DEFAULT nextval('pbx_tarifador_log_trf_id_seq'::regclass);


--
-- Name: tlvb_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_televendas_bloqueio ALTER COLUMN tlvb_id SET DEFAULT nextval('pbx_televendas_bloqueio_tlvb_id_seq'::regclass);


--
-- Name: tlvb_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_televendas_reg ALTER COLUMN tlvb_id SET DEFAULT nextval('pbx_televendas_reg_tlvb_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY pbx_teste ALTER COLUMN id SET DEFAULT nextval('pbx_teste_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_teste_permissao ALTER COLUMN id SET DEFAULT nextval('pbx_teste_permissao_id_seq'::regclass);


--
-- Name: umv_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_ura_movimento ALTER COLUMN umv_id SET DEFAULT nextval('pbx_ura_movimento_umv_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_usuarios_senha ALTER COLUMN id SET DEFAULT nextval('pbx_usuarios_senha_id_seq'::regclass);


--
-- Name: wappmsg_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_whatsapp_message ALTER COLUMN wappmsg_id SET DEFAULT nextval('pbx_whatsapp_message_wappmsg_id_seq'::regclass);


--
-- Name: wapp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_whatsapp_send ALTER COLUMN wapp_id SET DEFAULT nextval('pbx_whatsapp_send_wapp_id_seq'::regclass);


--
-- Name: wkf_email_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_workflow_emails ALTER COLUMN wkf_email_id SET DEFAULT nextval('pbx_workflow_emails_wkf_email_id_seq'::regclass);


--
-- Name: wkf_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_workflow_reg_envio_email ALTER COLUMN wkf_id SET DEFAULT nextval('pbx_workflow_reg_envio_email_wkf_id_seq'::regclass);


--
-- Name: wkf_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_workflow_reg_envio_email_mensal ALTER COLUMN wkf_id SET DEFAULT nextval('pbx_workflow_reg_envio_email_mensal_wkf_id_seq'::regclass);


--
-- Name: id_piperun; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY piperun ALTER COLUMN id_piperun SET DEFAULT nextval('piperun_id_piperun_seq'::regclass);


--
-- Name: dpto_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY rma_departamentos ALTER COLUMN dpto_id SET DEFAULT nextval('rma_departamentos_dpto_id_seq'::regclass);


--
-- Name: dif_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY sip_dif_versao ALTER COLUMN dif_id SET DEFAULT nextval('sip_dif_versao_dif_id_seq'::regclass);


--
-- Name: ver_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY sip_versao ALTER COLUMN ver_id SET DEFAULT nextval('sip_versao_ver_id_seq'::regclass);


--
-- Name: varq_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY sip_versao_arquivos ALTER COLUMN varq_id SET DEFAULT nextval('sip_versao_arquivos_varq_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY tmp_modelos_incluidos ALTER COLUMN id SET DEFAULT nextval('tmp_modelos_incluidos_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY tmp_troncos_incluidos ALTER COLUMN id SET DEFAULT nextval('tmp_troncos_incluidos_id_seq'::regclass);


--
-- Name: acp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_acompanha ALTER COLUMN acp_id SET DEFAULT nextval('vds_acompanha_acp_id_seq'::regclass);


--
-- Name: id_nec; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_api_encotrado ALTER COLUMN id_nec SET DEFAULT nextval('vds_api_encotrado_id_nec_seq'::regclass);


--
-- Name: id_nec; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_api_nao_encotrado ALTER COLUMN id_nec SET DEFAULT nextval('vds_api_nao_encotrado_id_nec_seq'::regclass);


--
-- Name: chm_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_chamadas ALTER COLUMN chm_id SET DEFAULT nextval('vds_chamadas_chm_id_seq'::regclass);


--
-- Name: id_chm_diario; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_chamadas_diario ALTER COLUMN id_chm_diario SET DEFAULT nextval('vds_chamadas_diario_id_chm_diario_seq'::regclass);


--
-- Name: clas_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_classificacoes ALTER COLUMN clas_id SET DEFAULT nextval('vds_classificacoes_clas_id_seq'::regclass);


--
-- Name: grp_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_grupos ALTER COLUMN grp_id SET DEFAULT nextval('vds_grupos_grp_id_seq'::regclass);


--
-- Name: log_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_log ALTER COLUMN log_id SET DEFAULT nextval('vds_log_log_id_seq'::regclass);


--
-- Name: plog_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_pesquisa_log ALTER COLUMN plog_id SET DEFAULT nextval('vds_pesquisa_log_plog_id_seq'::regclass);


--
-- Name: prt_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_protcolos ALTER COLUMN prt_id SET DEFAULT nextval('vds_protcolos_prt_id_seq'::regclass);


--
-- Name: id_unk; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_protcolos ALTER COLUMN id_unk SET DEFAULT nextval('vds_protcolos_id_unk_seq'::regclass);


--
-- Name: vdr_id; Type: DEFAULT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY vds_vendedores ALTER COLUMN vdr_id SET DEFAULT nextval('vds_vendedores_vdr_id_seq'::regclass);


--
-- Name: id_grupo; Type: DEFAULT; Schema: public; Owner: simplesip
--

ALTER TABLE ONLY vph_grupo_agenda ALTER COLUMN id_grupo SET DEFAULT nextval('vph_grupo_agenda_id_grupo_seq'::regclass);


--
-- Name: PK1; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_tipo
    ADD CONSTRAINT "PK1" PRIMARY KEY (itgt_id);


--
-- Name: PK4; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_protocolo
    ADD CONSTRAINT "PK4" PRIMARY KEY (itgp_id);


--
-- Name: PK5; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_configuracao
    ADD CONSTRAINT "PK5" PRIMARY KEY (itgc_id);


--
-- Name: PK6; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_metodo
    ADD CONSTRAINT "PK6" PRIMARY KEY (itgm_id);


--
-- Name: PK8; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_parametro
    ADD CONSTRAINT "PK8" PRIMARY KEY (itgp_id);


--
-- Name: PK9; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_contrato
    ADD CONSTRAINT "PK9" PRIMARY KEY (contr_id);


--
-- Name: ast_bilhetes_complemento_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY ast_bilhetes_complemento
    ADD CONSTRAINT ast_bilhetes_complemento_pkey PRIMARY KEY (id);


--
-- Name: ast_bilhetes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY ast_bilhetes
    ADD CONSTRAINT ast_bilhetes_pkey PRIMARY KEY (id_bilhetes);


--
-- Name: ast_eventos_dacs_new_ast_eventos_dac_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY ast_eventos_dacs
    ADD CONSTRAINT ast_eventos_dacs_new_ast_eventos_dac_pkey PRIMARY KEY (id);


--
-- Name: bx_campanha_usuarios_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_usuarios
    ADD CONSTRAINT bx_campanha_usuarios_pkey PRIMARY KEY (cmp_id, matricula);


--
-- Name: cdr_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY cdr
    ADD CONSTRAINT cdr_pkey PRIMARY KEY (id);


--
-- Name: fk_classifica; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_classifica_item
    ADD CONSTRAINT fk_classifica PRIMARY KEY (clit_id);


--
-- Name: grv_audita_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_audita
    ADD CONSTRAINT grv_audita_pkey PRIMARY KEY (aud_id);


--
-- Name: id; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_teste
    ADD CONSTRAINT id PRIMARY KEY (id);


--
-- Name: idxAgtUsuarios; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_agents_usuarios
    ADD CONSTRAINT "idxAgtUsuarios" PRIMARY KEY (id, login);


--
-- Name: idxAnotacoes; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_anotacoes
    ADD CONSTRAINT "idxAnotacoes" PRIMARY KEY (id_text);


--
-- Name: idxClas; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_classifica_atendimento
    ADD CONSTRAINT "idxClas" PRIMARY KEY (clas_id);


--
-- Name: idxFunNome; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_funcoes
    ADD CONSTRAINT "idxFunNome" UNIQUE (fun_nome);


--
-- Name: idxGrupNome; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_grupo
    ADD CONSTRAINT "idxGrupNome" UNIQUE (gp_nome, user_id);


--
-- Name: idxHoraMeta; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_hora_meta
    ADD CONSTRAINT "idxHoraMeta" PRIMARY KEY (hora_ini, hora_fim, tempo);


--
-- Name: idxHoraMinuto; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_hora_dia
    ADD CONSTRAINT "idxHoraMinuto" PRIMARY KEY (hora_ini, hora_fim);


--
-- Name: idxItgConfigNome; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_configuracao
    ADD CONSTRAINT "idxItgConfigNome" UNIQUE (itgc_nome);


--
-- Name: idxMat; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_media_atendimento
    ADD CONSTRAINT "idxMat" PRIMARY KEY (mat_dac, mat_data);


--
-- Name: idxMatDia; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_media_atendimento_dia
    ADD CONSTRAINT "idxMatDia" PRIMARY KEY (mat_dac, mat_data, mat_periodo);


--
-- Name: idxNomeFila; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_queues_grupos
    ADD CONSTRAINT "idxNomeFila" UNIQUE (nome);


--
-- Name: idxParam; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_parametros
    ADD CONSTRAINT "idxParam" PRIMARY KEY (id);


--
-- Name: idxPkClasReg; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_classifica_reg
    ADD CONSTRAINT "idxPkClasReg" PRIMARY KEY (matricula, clas_id, clit_id, id_bilhetes);


--
-- Name: idxWkfEmail; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_emails
    ADD CONSTRAINT "idxWkfEmail" UNIQUE (wkf_email);


--
-- Name: idx_cont_identificador; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_contato
    ADD CONSTRAINT idx_cont_identificador UNIQUE (list_id, cont_identificador);


--
-- Name: idxcontstatusnome; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_contato_status
    ADD CONSTRAINT idxcontstatusnome UNIQUE (ctst_nome);


--
-- Name: log_tarifa_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY log_tarifa
    ADD CONSTRAINT log_tarifa_pkey PRIMARY KEY (log_id);


--
-- Name: mkt_dados_anatel_scm_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY mkt_dados_anatel_scm
    ADD CONSTRAINT mkt_dados_anatel_scm_pkey PRIMARY KEY (scm_id);


--
-- Name: pbxTarifFranquiaIdMes; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_franquia
    ADD CONSTRAINT "pbxTarifFranquiaIdMes" PRIMARY KEY (contr_id, tff_mes);


--
-- Name: pbxTarifFranquiaMovimentoPrcd; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_franquia_movimento
    ADD CONSTRAINT "pbxTarifFranquiaMovimentoPrcd" PRIMARY KEY (tfm_id);


--
-- Name: pbxTarifRetarifa; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_retarifa
    ADD CONSTRAINT "pbxTarifRetarifa" PRIMARY KEY (ret_data, trr_id);


--
-- Name: pbx_administrador_funcoes_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_administrador_funcoes
    ADD CONSTRAINT pbx_administrador_funcoes_pkey PRIMARY KEY (fun_nome);


--
-- Name: pbx_agenda_servidores_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_agenda_servidores
    ADD CONSTRAINT pbx_agenda_servidores_pkey PRIMARY KEY (id_servidor);


--
-- Name: pbx_agendas_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_agendas
    ADD CONSTRAINT pbx_agendas_pkey PRIMARY KEY (id);


--
-- Name: pbx_agente_funcoes_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_agente_funcoes
    ADD CONSTRAINT pbx_agente_funcoes_pkey PRIMARY KEY (fun_nome);


--
-- Name: pbx_arquivo_som_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_arquivo_som
    ADD CONSTRAINT pbx_arquivo_som_pkey PRIMARY KEY (arq_id);


--
-- Name: pbx_audita_full_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_audita_full
    ADD CONSTRAINT pbx_audita_full_pkey PRIMARY KEY (full_id);


--
-- Name: pbx_backup_arquivos_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup_arquivos
    ADD CONSTRAINT pbx_backup_arquivos_pkey PRIMARY KEY (arq_id);


--
-- Name: pbx_backup_configuracao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup_configuracao
    ADD CONSTRAINT pbx_backup_configuracao_pkey PRIMARY KEY (cfg_id);


--
-- Name: pbx_backup_destino_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup_destino
    ADD CONSTRAINT pbx_backup_destino_pkey PRIMARY KEY (dst_id);


--
-- Name: pbx_backup_frequencia_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup_frequencia
    ADD CONSTRAINT pbx_backup_frequencia_pkey PRIMARY KEY (frq_id);


--
-- Name: pbx_backup_frequencia_qtde_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup_frequencia_qtde
    ADD CONSTRAINT pbx_backup_frequencia_qtde_pkey PRIMARY KEY (qt_id);


--
-- Name: pbx_backup_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup
    ADD CONSTRAINT pbx_backup_pkey PRIMARY KEY (bkp_id);


--
-- Name: pbx_backup_protocolo_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup_protocolo
    ADD CONSTRAINT pbx_backup_protocolo_pkey PRIMARY KEY (prt_id);


--
-- Name: pbx_backup_tipo_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_backup_tipo
    ADD CONSTRAINT pbx_backup_tipo_pkey PRIMARY KEY (tp_id);


--
-- Name: pbx_bilhetes_complemento_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_bilhetes_complemento
    ADD CONSTRAINT pbx_bilhetes_complemento_pkey PRIMARY KEY (id);


--
-- Name: pbx_bilhetes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_bilhetes
    ADD CONSTRAINT pbx_bilhetes_pkey PRIMARY KEY (id_bilhetes);


--
-- Name: pbx_bilhetes_wpp_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_bilhetes_wpp
    ADD CONSTRAINT pbx_bilhetes_wpp_pkey PRIMARY KEY (id_bilhetes);


--
-- Name: pbx_bloco_de_notas_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_bloco_de_notas
    ADD CONSTRAINT pbx_bloco_de_notas_pkey PRIMARY KEY ("TextoCod");


--
-- Name: pbx_cadastro_funcoes_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cadastro_funcoes
    ADD CONSTRAINT pbx_cadastro_funcoes_pkey PRIMARY KEY (id);


--
-- Name: pbx_campanha_contato_display_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_contato_display
    ADD CONSTRAINT pbx_campanha_contato_display_pkey PRIMARY KEY (disp_id);


--
-- Name: pbx_campanha_contato_fone_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_contato_fone
    ADD CONSTRAINT pbx_campanha_contato_fone_pkey PRIMARY KEY (conf_id);


--
-- Name: pbx_campanha_contato_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_contato
    ADD CONSTRAINT pbx_campanha_contato_pkey PRIMARY KEY (cont_id);


--
-- Name: pbx_campanha_contato_status_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_contato_status
    ADD CONSTRAINT pbx_campanha_contato_status_pkey PRIMARY KEY (ctst_id);


--
-- Name: pbx_campanha_lista_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_lista
    ADD CONSTRAINT pbx_campanha_lista_pkey PRIMARY KEY (list_id);


--
-- Name: pbx_campanha_operacao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_operacao
    ADD CONSTRAINT pbx_campanha_operacao_pkey PRIMARY KEY (cmpo_id);


--
-- Name: pbx_campanha_parametros_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_parametros
    ADD CONSTRAINT pbx_campanha_parametros_pkey PRIMARY KEY (id_param);


--
-- Name: pbx_campanha_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha
    ADD CONSTRAINT pbx_campanha_pkey PRIMARY KEY (cmp_id);


--
-- Name: pbx_campanha_registro_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_registro
    ADD CONSTRAINT pbx_campanha_registro_pkey PRIMARY KEY (id_cmpr);


--
-- Name: pbx_campanha_status_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_status
    ADD CONSTRAINT pbx_campanha_status_pkey PRIMARY KEY (cpst_id);


--
-- Name: pbx_campanha_template_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_template
    ADD CONSTRAINT pbx_campanha_template_pkey PRIMARY KEY (id_tpl);


--
-- Name: pbx_campanha_tipo_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_campanha_tipo
    ADD CONSTRAINT pbx_campanha_tipo_pkey PRIMARY KEY (ctp_id);


--
-- Name: pbx_canais_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_canais
    ADD CONSTRAINT pbx_canais_pkey PRIMARY KEY (uniqueid);


--
-- Name: pbx_centro_custo_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_centro_custo
    ADD CONSTRAINT pbx_centro_custo_pkey PRIMARY KEY (cc_id);


--
-- Name: pbx_chamada_ramal_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_chamada_ramal
    ADD CONSTRAINT pbx_chamada_ramal_pkey PRIMARY KEY (chdr_id);


--
-- Name: pbx_chefe_secretaria_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_chefe_secretaria
    ADD CONSTRAINT pbx_chefe_secretaria_pkey PRIMARY KEY (numero, excecao);


--
-- Name: pbx_cliente_anotacoes_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente_anotacoes
    ADD CONSTRAINT pbx_cliente_anotacoes_pkey PRIMARY KEY (cla_id);


--
-- Name: pbx_cliente_audio_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente_audio
    ADD CONSTRAINT pbx_cliente_audio_pkey PRIMARY KEY (clau_id);


--
-- Name: pbx_cliente_contato_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente_contato
    ADD CONSTRAINT pbx_cliente_contato_pkey PRIMARY KEY (clc_id);


--
-- Name: pbx_cliente_fornecedor_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente_fornecedor
    ADD CONSTRAINT pbx_cliente_fornecedor_pkey PRIMARY KEY (cfr_id);


--
-- Name: pbx_cliente_origem_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente_origem
    ADD CONSTRAINT pbx_cliente_origem_pkey PRIMARY KEY (clo_id);


--
-- Name: pbx_cliente_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente
    ADD CONSTRAINT pbx_cliente_pkey PRIMARY KEY (client_id);


--
-- Name: pbx_cliente_referencia_vendedor_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente_referencia_vendedor
    ADD CONSTRAINT pbx_cliente_referencia_vendedor_pkey PRIMARY KEY (id_ref_vendedor);


--
-- Name: pbx_cliente_segmento_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cliente_segmento
    ADD CONSTRAINT pbx_cliente_segmento_pkey PRIMARY KEY (csg_id);


--
-- Name: pbx_consulta_ddd_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_consulta_ddd
    ADD CONSTRAINT pbx_consulta_ddd_pkey PRIMARY KEY (id);


--
-- Name: pbx_contextos_operacoes_pk; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_contextos_operacoes
    ADD CONSTRAINT pbx_contextos_operacoes_pk PRIMARY KEY (ctop_tipo, ctop_contexto);


--
-- Name: pbx_controle_acesso_item_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_controle_acesso_item
    ADD CONSTRAINT pbx_controle_acesso_item_pkey PRIMARY KEY (acsi_id);


--
-- Name: pbx_controle_acesso_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_controle_acesso
    ADD CONSTRAINT pbx_controle_acesso_pkey PRIMARY KEY (acs_id);


--
-- Name: pbx_dac_usuario_id_dac_usu_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_dac_usuario
    ADD CONSTRAINT pbx_dac_usuario_id_dac_usu_key UNIQUE (id_dac_usu);


--
-- Name: pbx_dac_usuario_new_id_dac_usu_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_dac_usuario
    ADD CONSTRAINT pbx_dac_usuario_new_id_dac_usu_key UNIQUE (id_dac_usu);


--
-- Name: pbx_dahdi_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_dahdi
    ADD CONSTRAINT pbx_dahdi_pkey PRIMARY KEY (id);


--
-- Name: pbx_dbtype_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_dbtype
    ADD CONSTRAINT pbx_dbtype_pkey PRIMARY KEY (db_prefix);


--
-- Name: pbx_ddd_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_ddd
    ADD CONSTRAINT pbx_ddd_pkey PRIMARY KEY (id);


--
-- Name: pbx_departamentos_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_departamentos
    ADD CONSTRAINT pbx_departamentos_pkey PRIMARY KEY (id);


--
-- Name: pbx_empresa_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_empresa
    ADD CONSTRAINT pbx_empresa_pkey PRIMARY KEY (id);


--
-- Name: pbx_estrategia_distribuicao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_estrategia_distribuicao
    ADD CONSTRAINT pbx_estrategia_distribuicao_pkey PRIMARY KEY (est_id);


--
-- Name: pbx_eventos_agentes_wpp_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_eventos_agentes_wpp
    ADD CONSTRAINT pbx_eventos_agentes_wpp_pkey PRIMARY KEY (id);


--
-- Name: pbx_eventos_dacs_new_pbx_eventos_dac_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_eventos_dacs
    ADD CONSTRAINT pbx_eventos_dacs_new_pbx_eventos_dac_pkey PRIMARY KEY (id);


--
-- Name: pbx_eventos_dacs_wpp_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_eventos_dacs_wpp
    ADD CONSTRAINT pbx_eventos_dacs_wpp_pkey PRIMARY KEY (id);


--
-- Name: pbx_eventos_transbordo_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_eventos_transbordo
    ADD CONSTRAINT pbx_eventos_transbordo_pkey PRIMARY KEY (trbd_id);


--
-- Name: pbx_eventos_usuarios_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_eventos_agentes
    ADD CONSTRAINT pbx_eventos_usuarios_pkey PRIMARY KEY (id);


--
-- Name: pbx_fornecedor_permissao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_fornecedor_permissao
    ADD CONSTRAINT pbx_fornecedor_permissao_pkey PRIMARY KEY (id_cfr_permissao);


--
-- Name: pbx_funcoes_internas_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_funcoes_internas
    ADD CONSTRAINT pbx_funcoes_internas_pkey PRIMARY KEY (id_prog);


--
-- Name: pbx_grupo_ura_ramal_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_grupo_ura_ramal
    ADD CONSTRAINT pbx_grupo_ura_ramal_pkey PRIMARY KEY (id);


--
-- Name: pbx_horarios_itens_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_horarios_itens
    ADD CONSTRAINT pbx_horarios_itens_pkey PRIMARY KEY (id);


--
-- Name: pbx_horarios_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_horarios
    ADD CONSTRAINT pbx_horarios_pkey PRIMARY KEY (id);


--
-- Name: pbx_integracao_reg_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_reg
    ADD CONSTRAINT pbx_integracao_reg_pkey PRIMARY KEY (reg_id);


--
-- Name: pbx_khomp_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_khomp
    ADD CONSTRAINT pbx_khomp_pkey PRIMARY KEY (id);


--
-- Name: pbx_kingdialer_bloqueios_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_kingdialer_bloqueios
    ADD CONSTRAINT pbx_kingdialer_bloqueios_pkey PRIMARY KEY (id_bloq);


--
-- Name: pbx_kingdialer_campanha_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_kingdialer_campanha
    ADD CONSTRAINT pbx_kingdialer_campanha_pkey PRIMARY KEY (id_camp_king);


--
-- Name: pbx_kingdialer_config_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_kingdialer_config
    ADD CONSTRAINT pbx_kingdialer_config_pkey PRIMARY KEY (id_king);


--
-- Name: pbx_ligueme_gratis_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_ligueme_gratis
    ADD CONSTRAINT pbx_ligueme_gratis_pkey PRIMARY KEY (id_ligueme_gratis);


--
-- Name: pbx_links_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_links
    ADD CONSTRAINT pbx_links_pkey PRIMARY KEY (linkid);


--
-- Name: pbx_lista_discador_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_lista_discador
    ADD CONSTRAINT pbx_lista_discador_pkey PRIMARY KEY (ld_id);


--
-- Name: pbx_lista_negra_palavras_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_lista_negra_palavras
    ADD CONSTRAINT pbx_lista_negra_palavras_pkey PRIMARY KEY (id);


--
-- Name: pbx_log_forms_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_log_forms
    ADD CONSTRAINT pbx_log_forms_pkey PRIMARY KEY (log_id);


--
-- Name: pbx_message_wpp_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_message_wpp
    ADD CONSTRAINT pbx_message_wpp_pkey PRIMARY KEY (id);


--
-- Name: pbx_monitora_abdagi_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_monitora_abdagi
    ADD CONSTRAINT pbx_monitora_abdagi_pkey PRIMARY KEY (m_id);


--
-- Name: pbx_motivos_pausas_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_motivos_pausas
    ADD CONSTRAINT pbx_motivos_pausas_pkey PRIMARY KEY (id);


--
-- Name: pbx_municipios_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_municipios
    ADD CONSTRAINT pbx_municipios_pkey PRIMARY KEY (id);


--
-- Name: pbx_nao_perturbe_cliente_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_nao_perturbe_cliente
    ADD CONSTRAINT pbx_nao_perturbe_cliente_pkey PRIMARY KEY (npc_id);


--
-- Name: pbx_nao_perturbe_controle_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_nao_perturbe_controle
    ADD CONSTRAINT pbx_nao_perturbe_controle_pkey PRIMARY KEY (np_id);


--
-- Name: pbx_normaliza_agenda_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_normaliza_agenda
    ADD CONSTRAINT pbx_normaliza_agenda_pkey PRIMARY KEY (id);


--
-- Name: pbx_notifica_media_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_notifica_media
    ADD CONSTRAINT pbx_notifica_media_pkey PRIMARY KEY (id);


--
-- Name: pbx_pausa_automatica_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_pausa_automatica
    ADD CONSTRAINT pbx_pausa_automatica_pkey PRIMARY KEY (iddac);


--
-- Name: pbx_pesquisa_liberacao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_liberacao
    ADD CONSTRAINT pbx_pesquisa_liberacao_pkey PRIMARY KEY (pl_id);


--
-- Name: pbx_pesquisa_log_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_log
    ADD CONSTRAINT pbx_pesquisa_log_pkey PRIMARY KEY (plog_id);


--
-- Name: pbx_pesquisa_movimento_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_movimento
    ADD CONSTRAINT pbx_pesquisa_movimento_pkey PRIMARY KEY (pm_id);


--
-- Name: pbx_pesquisa_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa
    ADD CONSTRAINT pbx_pesquisa_pkey PRIMARY KEY (pp_id);


--
-- Name: pbx_pesquisa_questao_tipo_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_questao_tipo
    ADD CONSTRAINT pbx_pesquisa_questao_tipo_pkey PRIMARY KEY (pqt_id);


--
-- Name: pbx_pesquisa_regitra_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_regitra
    ADD CONSTRAINT pbx_pesquisa_regitra_pkey PRIMARY KEY (uniqueid);


--
-- Name: pbx_porta_operadora_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_operadoras
    ADD CONSTRAINT pbx_porta_operadora_pkey PRIMARY KEY (oper_id);


--
-- Name: pbx_prepago_movimento_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_prepago_movimento
    ADD CONSTRAINT pbx_prepago_movimento_pkey PRIMARY KEY (prm_id);


--
-- Name: pbx_prioridades_atendimento_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_prioridades_atendimento
    ADD CONSTRAINT pbx_prioridades_atendimento_pkey PRIMARY KEY (id);


--
-- Name: pbx_ramais_agenda_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_ramais_agenda
    ADD CONSTRAINT pbx_ramais_agenda_pkey PRIMARY KEY (rma_telefone);


--
-- Name: pbx_relatorio_ordena_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_relatorio_ordena
    ADD CONSTRAINT pbx_relatorio_ordena_pkey PRIMARY KEY (ord_id);


--
-- Name: pbx_relatorio_ordena_set_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_relatorio_ordena_set
    ADD CONSTRAINT pbx_relatorio_ordena_set_pkey PRIMARY KEY (ord_id);


--
-- Name: pbx_rename_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_rename
    ADD CONSTRAINT pbx_rename_pkey PRIMARY KEY (renameid);


--
-- Name: pbx_replica_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_replica
    ADD CONSTRAINT pbx_replica_pkey PRIMARY KEY (rpl_id);


--
-- Name: pbx_servers_sinc_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_servers_sinc
    ADD CONSTRAINT pbx_servers_sinc_pkey PRIMARY KEY (server_id);


--
-- Name: pbx_servicos_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_servicos
    ADD CONSTRAINT pbx_servicos_pkey PRIMARY KEY (serv_id);


--
-- Name: pbx_sites_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_sites
    ADD CONSTRAINT pbx_sites_pkey PRIMARY KEY (id);


--
-- Name: pbx_sms_send_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_sms_send
    ADD CONSTRAINT pbx_sms_send_pkey PRIMARY KEY (sms_id);


--
-- Name: pbx_status_ligacao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_status_ligacao
    ADD CONSTRAINT pbx_status_ligacao_pkey PRIMARY KEY (stat_id);


--
-- Name: pbx_status_retorno_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_status_retorno
    ADD CONSTRAINT pbx_status_retorno_pkey PRIMARY KEY (strt_id);


--
-- Name: pbx_supervisor_agentes_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_supervisor_agentes
    ADD CONSTRAINT pbx_supervisor_agentes_pkey PRIMARY KEY (id);


--
-- Name: pbx_supervisor_dacs_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_supervisor_dacs
    ADD CONSTRAINT pbx_supervisor_dacs_pkey PRIMARY KEY (id);


--
-- Name: pbx_supervisor_funcoes_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_supervisor_funcoes
    ADD CONSTRAINT pbx_supervisor_funcoes_pkey PRIMARY KEY (fun_nome);


--
-- Name: pbx_tab_ddd_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tab_ddd
    ADD CONSTRAINT pbx_tab_ddd_pkey PRIMARY KEY (idddd);


--
-- Name: pbx_tarif_contrato_preco_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_contrato_preco
    ADD CONSTRAINT pbx_tarif_contrato_preco_pkey PRIMARY KEY (prc_id);


--
-- Name: pbx_tarif_registra_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_registra
    ADD CONSTRAINT pbx_tarif_registra_pkey PRIMARY KEY (trr_id);


--
-- Name: pbx_tarif_tipo_franquia_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_tipo_franquia
    ADD CONSTRAINT pbx_tarif_tipo_franquia_pkey PRIMARY KEY (tfq_id);


--
-- Name: pbx_tarifa_tipo_preco_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarifa_tipo_preco
    ADD CONSTRAINT pbx_tarifa_tipo_preco_pkey PRIMARY KEY (ttp_id);


--
-- Name: pbx_tarifador_log_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_tarifador_log
    ADD CONSTRAINT pbx_tarifador_log_pkey PRIMARY KEY (trf_id);


--
-- Name: pbx_televendas_bloqueio_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_televendas_bloqueio
    ADD CONSTRAINT pbx_televendas_bloqueio_pkey PRIMARY KEY (tlvb_id);


--
-- Name: pbx_televendas_reg_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_televendas_reg
    ADD CONSTRAINT pbx_televendas_reg_pkey PRIMARY KEY (tlvb_id);


--
-- Name: pbx_teste_permissao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_teste_permissao
    ADD CONSTRAINT pbx_teste_permissao_pkey PRIMARY KEY (id);


--
-- Name: pbx_tipo_ligacao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tipo_ligacao
    ADD CONSTRAINT pbx_tipo_ligacao_pkey PRIMARY KEY (tplg_codigo);


--
-- Name: pbx_troncos_dahdi_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_troncos_dahdi
    ADD CONSTRAINT pbx_troncos_dahdi_pkey PRIMARY KEY (id);


--
-- Name: pbx_troncos_khomp_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_troncos_khomp
    ADD CONSTRAINT pbx_troncos_khomp_pkey PRIMARY KEY (id);


--
-- Name: pbx_turnos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_turnos
    ADD CONSTRAINT pbx_turnos_pkey PRIMARY KEY (id);


--
-- Name: pbx_uf_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_uf
    ADD CONSTRAINT pbx_uf_pkey PRIMARY KEY (uf);


--
-- Name: pbx_ura_movimento_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_ura_movimento
    ADD CONSTRAINT pbx_ura_movimento_pkey PRIMARY KEY (umv_id);


--
-- Name: pbx_urls_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_urls
    ADD CONSTRAINT pbx_urls_pkey PRIMARY KEY (id);


--
-- Name: pbx_usuarios_new_matricula_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_usuarios
    ADD CONSTRAINT pbx_usuarios_new_matricula_key UNIQUE (matricula);


--
-- Name: pbx_usuarios_new_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_usuarios
    ADD CONSTRAINT pbx_usuarios_new_pkey PRIMARY KEY (id);


--
-- Name: pbx_usuarios_senha_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_usuarios_senha
    ADD CONSTRAINT pbx_usuarios_senha_pkey PRIMARY KEY (id);


--
-- Name: pbx_whatsapp_message_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_whatsapp_message
    ADD CONSTRAINT pbx_whatsapp_message_pkey PRIMARY KEY (wappmsg_id);


--
-- Name: pbx_whatsapp_send_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_whatsapp_send
    ADD CONSTRAINT pbx_whatsapp_send_pkey PRIMARY KEY (wapp_id);


--
-- Name: pbx_workflow_emails_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_emails
    ADD CONSTRAINT pbx_workflow_emails_pkey PRIMARY KEY (wkf_email_id);


--
-- Name: pbx_workflow_parametros_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_parametros
    ADD CONSTRAINT pbx_workflow_parametros_pkey PRIMARY KEY (wkf_id);


--
-- Name: pbx_workflow_reg_envio_email_mensal_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_reg_envio_email_mensal
    ADD CONSTRAINT pbx_workflow_reg_envio_email_mensal_pkey PRIMARY KEY (wkf_id);


--
-- Name: pbx_workflow_reg_envio_email_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_reg_envio_email
    ADD CONSTRAINT pbx_workflow_reg_envio_email_pkey PRIMARY KEY (wkf_id);


--
-- Name: pbx_workflow_reg_envio_mensal_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_reg_envio_mensal
    ADD CONSTRAINT pbx_workflow_reg_envio_mensal_pkey PRIMARY KEY (wkf_data_envio);


--
-- Name: pbx_workflow_reg_envio_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_reg_envio
    ADD CONSTRAINT pbx_workflow_reg_envio_pkey PRIMARY KEY (wkf_data_envio);


--
-- Name: piperun_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY piperun
    ADD CONSTRAINT piperun_pkey PRIMARY KEY (id_piperun);


--
-- Name: pkAbandonadasSemRetorno; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_abandonadas_semretorno
    ADD CONSTRAINT "pkAbandonadasSemRetorno" PRIMARY KEY (abdsr_uniqueid, abdsr_fila);


--
-- Name: pkAgenda; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_agenda
    ADD CONSTRAINT "pkAgenda" PRIMARY KEY (id);


--
-- Name: pkAgentsAgents; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_agents_agents
    ADD CONSTRAINT "pkAgentsAgents" PRIMARY KEY (maxlogintries);


--
-- Name: pkAgentsGeneral; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_agents_general
    ADD CONSTRAINT "pkAgentsGeneral" PRIMARY KEY (persistentagents, multiplelogin);


--
-- Name: pkAnuncios; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_anuncios
    ADD CONSTRAINT "pkAnuncios" PRIMARY KEY (id);


--
-- Name: pkCallback; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_callback
    ADD CONSTRAINT "pkCallback" PRIMARY KEY (id);


--
-- Name: pkCallbackNumeros; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_callback_numeros
    ADD CONSTRAINT "pkCallbackNumeros" PRIMARY KEY (id);


--
-- Name: pkCentroCustoRamais; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pbx_centro_custo_ramais
    ADD CONSTRAINT "pkCentroCustoRamais" PRIMARY KEY (cc_id, ramal);


--
-- Name: pkChamadasConfere; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY vds_chamadas_confere
    ADD CONSTRAINT "pkChamadasConfere" PRIMARY KEY (emp_id, cfr_data, cfr_fila);


--
-- Name: pkClasDacs; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_classifica_dacs
    ADD CONSTRAINT "pkClasDacs" PRIMARY KEY (id_dac, clas_id);


--
-- Name: pkClassificacoesConfere; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY vds_classificacoes_confere
    ADD CONSTRAINT "pkClassificacoesConfere" PRIMARY KEY (emp_id, cfr_data, cfr_fila);


--
-- Name: pkConferenciaId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_conferencia
    ADD CONSTRAINT "pkConferenciaId" PRIMARY KEY (id);


--
-- Name: pkContextoCanais; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_contextos_canais
    ADD CONSTRAINT "pkContextoCanais" PRIMARY KEY (id);


--
-- Name: pkContextoCanaisTmp; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_contextos_canais_tmp
    ADD CONSTRAINT "pkContextoCanaisTmp" PRIMARY KEY (id);


--
-- Name: pkContextoOpecaoTmp; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_contextos_opcoes_tmp
    ADD CONSTRAINT "pkContextoOpecaoTmp" PRIMARY KEY (id);


--
-- Name: pkContrbId; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_contribuinte
    ADD CONSTRAINT "pkContrbId" PRIMARY KEY (contrib_id);


--
-- Name: pkDacUsuario; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_dac_usuario
    ADD CONSTRAINT "pkDacUsuario" PRIMARY KEY (id_dac_usu);


--
-- Name: pkDgvId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_dgv
    ADD CONSTRAINT "pkDgvId" PRIMARY KEY (id);


--
-- Name: pkFuncId; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_funcoes
    ADD CONSTRAINT "pkFuncId" PRIMARY KEY (fun_id);


--
-- Name: pkGpUserId; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_grupo_usuario
    ADD CONSTRAINT "pkGpUserId" PRIMARY KEY (user_id, gp_id);


--
-- Name: pkGrupId; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_grupo
    ADD CONSTRAINT "pkGrupId" PRIMARY KEY (gp_id);


--
-- Name: pkGrupoAudioRamal; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_grupo_audio_ramal
    ADD CONSTRAINT "pkGrupoAudioRamal" PRIMARY KEY (nome, gp_id);


--
-- Name: pkGrupoFunc; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_grupo_funcoes
    ADD CONSTRAINT "pkGrupoFunc" PRIMARY KEY (gp_id, fun_id);


--
-- Name: pkGrupoRevendas; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_grupo_revendas
    ADD CONSTRAINT "pkGrupoRevendas" PRIMARY KEY (gp_id, emp_id);


--
-- Name: pkIaxPbxId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_iax_pbx
    ADD CONSTRAINT "pkIaxPbxId" PRIMARY KEY (id);


--
-- Name: pkIdDacs; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_queues_grupos
    ADD CONSTRAINT "pkIdDacs" PRIMARY KEY (id);


--
-- Name: pkIdDisa; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_disa
    ADD CONSTRAINT "pkIdDisa" PRIMARY KEY (id);


--
-- Name: pkIdGrupos; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_grupos
    ADD CONSTRAINT "pkIdGrupos" PRIMARY KEY (id);


--
-- Name: pkIdUra; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_ura
    ADD CONSTRAINT "pkIdUra" PRIMARY KEY (id);


--
-- Name: pkIdxConfPadrao; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_conf_padrao
    ADD CONSTRAINT "pkIdxConfPadrao" PRIMARY KEY (id_conf);


--
-- Name: pkIndisponivel; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_indisponivel
    ADD CONSTRAINT "pkIndisponivel" PRIMARY KEY (id_dac, ind_data, ind_inicio, ind_fim);


--
-- Name: pkIntid; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_integracao_dados
    ADD CONSTRAINT "pkIntid" PRIMARY KEY (int_id);


--
-- Name: pkListaNegra; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_listanegra
    ADD CONSTRAINT "pkListaNegra" PRIMARY KEY (id);


--
-- Name: pkModeloOpcao; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_contextos_opcoes
    ADD CONSTRAINT "pkModeloOpcao" PRIMARY KEY (id);


--
-- Name: pkModelos; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_contextos_modelos
    ADD CONSTRAINT "pkModelos" PRIMARY KEY (id);


--
-- Name: pkModelostmp; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_contextos_modelos_tmp
    ADD CONSTRAINT "pkModelostmp" PRIMARY KEY (id);


--
-- Name: pkMunicipioClassifica; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_municipio_classifica
    ADD CONSTRAINT "pkMunicipioClassifica" PRIMARY KEY (mun_id);


--
-- Name: pkMunicipioPrefixo; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_municipio_prefixo
    ADD CONSTRAINT "pkMunicipioPrefixo" PRIMARY KEY (mun_id, prx_prefixo);


--
-- Name: pkPbxAbandonadasStatus; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_abandonadas_status
    ADD CONSTRAINT "pkPbxAbandonadasStatus" PRIMARY KEY (uniqueid, fila, matricula);


--
-- Name: pkPbxAvisoFranquia; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_aviso_franquia_reg
    ADD CONSTRAINT "pkPbxAvisoFranquia" PRIMARY KEY (contrato, data_aviso);


--
-- Name: pkPbxIndisponivelFila; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_indisponivel_fila
    ADD CONSTRAINT "pkPbxIndisponivelFila" PRIMARY KEY (id_dac, matricula, idf_entrada);


--
-- Name: pkPbxListanegraRota; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_listanegra_rota
    ADD CONSTRAINT "pkPbxListanegraRota" PRIMARY KEY (id_rota, id_lista, tipo_rota);


--
-- Name: pkPbxOperadoraRel; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_operadora_rel
    ADD CONSTRAINT "pkPbxOperadoraRel" PRIMARY KEY (oper_spid, oper_spid_rel);


--
-- Name: pkPbxRegistraClassificacao; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_registra_classificacao
    ADD CONSTRAINT "pkPbxRegistraClassificacao" PRIMARY KEY (id_dac, matricula, rgc_entrada);


--
-- Name: pkPbxSequencia; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_sequencia
    ADD CONSTRAINT "pkPbxSequencia" PRIMARY KEY (name_table);


--
-- Name: pkPbxStatusContatoCampanha; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_status_contato_campanha
    ADD CONSTRAINT "pkPbxStatusContatoCampanha" PRIMARY KEY (ctst_id, cmp_id);


--
-- Name: pkPbxTarifContratoTarifaZero; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tarif_contrato_tarifa_zero
    ADD CONSTRAINT "pkPbxTarifContratoTarifaZero" PRIMARY KEY (contr_id, trz_numero);


--
-- Name: pkPbxTroncosDgvId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_troncos_dgv
    ADD CONSTRAINT "pkPbxTroncosDgvId" PRIMARY KEY (id);


--
-- Name: pkPbxTroncosIaxId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_troncos_iax
    ADD CONSTRAINT "pkPbxTroncosIaxId" PRIMARY KEY (id);


--
-- Name: pkPbxTroncosSipId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_troncos_sip
    ADD CONSTRAINT "pkPbxTroncosSipId" PRIMARY KEY (id);


--
-- Name: pkPesqisaLiberacaoDac; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_liberacao_dacs
    ADD CONSTRAINT "pkPesqisaLiberacaoDac" PRIMARY KEY (pl_id, id_dac);


--
-- Name: pkProto; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pbx_protocolo_reg
    ADD CONSTRAINT "pkProto" PRIMARY KEY (ano, numproto);


--
-- Name: pkProtocolosConfere; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY vds_protocolos_confere
    ADD CONSTRAINT "pkProtocolosConfere" PRIMARY KEY (emp_id, cfr_data);


--
-- Name: pkRamaisPbxId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_ramais_pbx
    ADD CONSTRAINT "pkRamaisPbxId" PRIMARY KEY (id);


--
-- Name: pkReplicaHost; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_replica_host
    ADD CONSTRAINT "pkReplicaHost" PRIMARY KEY (rpl_id, server_id);


--
-- Name: pkRotasSaidaCanaisId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_rotas_saida_canais
    ADD CONSTRAINT "pkRotasSaidaCanaisId" PRIMARY KEY (id);


--
-- Name: pkRotasSaidaId; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_rotas_saida
    ADD CONSTRAINT "pkRotasSaidaId" PRIMARY KEY (id);


--
-- Name: pkRotasSaidaModeloIdModelo; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_rotas_saida_modelos
    ADD CONSTRAINT "pkRotasSaidaModeloIdModelo" PRIMARY KEY (id_rota, modelo);


--
-- Name: pkRplHosts; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_replica_hosts
    ADD CONSTRAINT "pkRplHosts" PRIMARY KEY (host_id, rpl_id);


--
-- Name: pkTempo; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_tempo_meta
    ADD CONSTRAINT "pkTempo" PRIMARY KEY (tempo);


--
-- Name: pkUsuariosConfere; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY vds_usuarios_confere
    ADD CONSTRAINT "pkUsuariosConfere" PRIMARY KEY (emp_id, cfr_matricula);


--
-- Name: pkVdsGruposEmpresas; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_grupos_empresas
    ADD CONSTRAINT "pkVdsGruposEmpresas" PRIMARY KEY (grp_id, emp_id);


--
-- Name: pk_grupoagenda; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY vph_grupo_agenda
    ADD CONSTRAINT pk_grupoagenda PRIMARY KEY (id_grupo);


--
-- Name: pk_pbx_fila_audios; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_fila_audios
    ADD CONSTRAINT pk_pbx_fila_audios PRIMARY KEY (id, gp_id);


--
-- Name: pk_pbx_fila_grupos; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_fila_grupos
    ADD CONSTRAINT pk_pbx_fila_grupos PRIMARY KEY (id, gp_id);


--
-- Name: [REDACTED] Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY pbx_pausa_grupo_usuario
    ADD CONSTRAINT [REDACTED]PRIMARY KEY (id, gp_id);


--
-- Name: [REDACTED] Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_opcoes
    ADD CONSTRAINT [REDACTED]PRIMARY KEY (pq_id, po_id);


--
-- Name: [REDACTED] Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_pesquisa_questoes
    ADD CONSTRAINT [REDACTED]PRIMARY KEY (pp_id, pq_id);


--
-- Name: [REDACTED] Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_workflow_emails_dacs
    ADD CONSTRAINT [REDACTED]PRIMARY KEY (wkf_email_id, nome_dac);


--
-- Name: pkcsusuario; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cs_usuarios
    ADD CONSTRAINT pkcsusuario PRIMARY KEY (id);


--
-- Name: pkmktRegiaoEstado; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY mkt_regiao_estados
    ADD CONSTRAINT "pkmktRegiaoEstado" PRIMARY KEY (reg_sigla, reg_uf);


--
-- Name: pkpbxServicosRegistra; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_servicos_registra
    ADD CONSTRAINT "pkpbxServicosRegistra" PRIMARY KEY (uniqueid, serv_id);


--
-- Name: pkrotassaidaramais; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_rotas_saida_ramais
    ADD CONSTRAINT pkrotassaidaramais PRIMARY KEY (id_rota, ramal);


--
-- Name: rma_departamentos_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY rma_departamentos
    ADD CONSTRAINT rma_departamentos_pkey PRIMARY KEY (dpto_id);


--
-- Name: rma_depto_ramais_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY rma_depto_ramais
    ADD CONSTRAINT rma_depto_ramais_pkey PRIMARY KEY (nome);


--
-- Name: sip_dif_versao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY sip_dif_versao
    ADD CONSTRAINT sip_dif_versao_pkey PRIMARY KEY (dif_id);


--
-- Name: sip_ramais_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_sip_ramais
    ADD CONSTRAINT sip_ramais_pkey PRIMARY KEY (id);


--
-- Name: sip_versao_arquivos_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY sip_versao_arquivos
    ADD CONSTRAINT sip_versao_arquivos_pkey PRIMARY KEY (varq_id);


--
-- Name: sip_versao_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY sip_versao
    ADD CONSTRAINT sip_versao_pkey PRIMARY KEY (ver_id);


--
-- Name: unkcsusermatricula; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_cs_usuarios
    ADD CONSTRAINT unkcsusermatricula UNIQUE (matricula);


--
-- Name: unqClasDesc; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_classifica_atendimento
    ADD CONSTRAINT "unqClasDesc" UNIQUE (clas_descricao);


--
-- Name: unqClitDescricao; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_classifica_item
    ADD CONSTRAINT "unqClitDescricao" UNIQUE (clas_id, clit_descricao);


--
-- Name: vds_acompanha_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_acompanha
    ADD CONSTRAINT vds_acompanha_pkey PRIMARY KEY (acp_id);


--
-- Name: vds_api_encotrado_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_api_encotrado
    ADD CONSTRAINT vds_api_encotrado_pkey PRIMARY KEY (id_nec);


--
-- Name: vds_api_nao_encotrado_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_api_nao_encotrado
    ADD CONSTRAINT vds_api_nao_encotrado_pkey PRIMARY KEY (id_nec);


--
-- Name: vds_chamadas_diario_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_chamadas_diario
    ADD CONSTRAINT vds_chamadas_diario_pkey PRIMARY KEY (id_chm_diario);


--
-- Name: vds_chamadas_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_chamadas
    ADD CONSTRAINT vds_chamadas_pkey PRIMARY KEY (chm_id);


--
-- Name: vds_classificacoes_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_classificacoes
    ADD CONSTRAINT vds_classificacoes_pkey PRIMARY KEY (clas_id);


--
-- Name: vds_empresas_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_empresas
    ADD CONSTRAINT vds_empresas_pkey PRIMARY KEY (emp_id);


--
-- Name: vds_grupos_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_grupos
    ADD CONSTRAINT vds_grupos_pkey PRIMARY KEY (grp_id);


--
-- Name: vds_log_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_log
    ADD CONSTRAINT vds_log_pkey PRIMARY KEY (log_id);


--
-- Name: vds_pesquisa_log_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_pesquisa_log
    ADD CONSTRAINT vds_pesquisa_log_pkey PRIMARY KEY (plog_id);


--
-- Name: vds_pesquisa_regitra_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_pesquisa_regitra
    ADD CONSTRAINT vds_pesquisa_regitra_pkey PRIMARY KEY (uniqueid);


--
-- Name: vds_protcolos_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_protcolos
    ADD CONSTRAINT vds_protcolos_pkey PRIMARY KEY (prt_id);


--
-- Name: vds_vendedores_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY vds_vendedores
    ADD CONSTRAINT vds_vendedores_pkey PRIMARY KEY (vdr_id);


--
-- Name: voicemail_usuarios_pkey; Type: CONSTRAINT; Schema: public; Owner: contacte; Tablespace: 
--

ALTER TABLE ONLY pbx_voicemail_usuarios
    ADD CONSTRAINT voicemail_usuarios_pkey PRIMARY KEY (id);


--
-- Name: vph_contato_agenda_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY vph_contato_agenda
    ADD CONSTRAINT vph_contato_agenda_pkey PRIMARY KEY (id_contato);


--
-- Name: vph_itens_contato_pkey; Type: CONSTRAINT; Schema: public; Owner: simplesip; Tablespace: 
--

ALTER TABLE ONLY vph_itens_contato
    ADD CONSTRAINT vph_itens_contato_pkey PRIMARY KEY (id_itcontato);


--
-- Name: dxVdsChamadasDiario; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsChamadasDiario" ON vds_chamadas_diario USING btree (id_pk_emp, data_ini, data_fim);


--
-- Name: dxVdsChamadasEmpData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsChamadasEmpData" ON vds_chamadas USING btree (emp_id, chm_data_bilhete);


--
-- Name: dxVdsChamadasUid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsChamadasUid" ON vds_chamadas USING btree (uid);


--
-- Name: dxVdsClassificacoes; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsClassificacoes" ON vds_classificacoes USING btree (clas_reg);


--
-- Name: dxVdsClassificacoesUid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsClassificacoesUid" ON vds_classificacoes USING btree (uid);


--
-- Name: dxVdsClassificacoesempId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsClassificacoesempId" ON vds_classificacoes USING btree (emp_id);


--
-- Name: dxVdsEmpresasempId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsEmpresasempId" ON vds_empresas USING btree (emp_id);


--
-- Name: dxVdsProtocolosEmpId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsProtocolosEmpId" ON vds_protcolos USING btree (emp_id);


--
-- Name: dxVdsProtocolosUid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsProtocolosUid" ON vds_protcolos USING btree (uid);


--
-- Name: dxVdsProtocolosUidParc; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "dxVdsProtocolosUidParc" ON vds_protcolos USING btree (uid, prt_proto_parceiro);


--
-- Name: evtAgtDacPausa; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "evtAgtDacPausa" ON pbx_eventos_agentes USING btree (entrada_pausa, id_dac);


--
-- Name: icxPbxAbandonadasSemretornoData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "icxPbxAbandonadasSemretornoData" ON pbx_abandonadas_semretorno USING btree (abdsr_data);


--
-- Name: icxPbxAbandonadasSemretornoDataFila; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "icxPbxAbandonadasSemretornoDataFila" ON pbx_abandonadas_semretorno USING btree (abdsr_data, abdsr_fila);


--
-- Name: idxAccountcode; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxAccountcode" ON pbx_bilhetes USING btree (accountcode);


--
-- Name: idxAstBilUniqueId; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxAstBilUniqueId" ON ast_bilhetes USING btree (uniqueid);


--
-- Name: idxAstBilhetesComplDirecao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAstBilhetesComplDirecao" ON ast_bilhetes_complemento USING btree (direcao);


--
-- Name: idxAstBilhetesComplUniqId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAstBilhetesComplUniqId" ON ast_bilhetes_complemento USING btree (uniqueid2);


--
-- Name: idxAstBilhetesComplUnqDir; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAstBilhetesComplUnqDir" ON ast_bilhetes_complemento USING btree (uniqueid2, direcao);


--
-- Name: idxAstBilhetesDataBilhete; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxAstBilhetesDataBilhete" ON ast_bilhetes USING btree (data_bilhete);


--
-- Name: idxAstCalldate; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxAstCalldate" ON ast_bilhetes USING btree (calldate);


--
-- Name: idxAstEvtDacsAgente; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAstEvtDacsAgente" ON ast_eventos_dacs USING btree (agente);


--
-- Name: idxAstEvtDacsFila; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAstEvtDacsFila" ON ast_eventos_dacs USING btree (fila);


--
-- Name: idxAstEvtDacsUid2; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAstEvtDacsUid2" ON ast_eventos_dacs USING btree (uid2);


--
-- Name: idxAuditaData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAuditaData" ON pbx_audita USING btree (aud_data);


--
-- Name: idxAuditaIdProg; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAuditaIdProg" ON pbx_audita USING btree (id_prog);


--
-- Name: idxAuditaUserReg; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxAuditaUserReg" ON pbx_audita USING btree (user_reg);


--
-- Name: idxBackupConfiguracaoDesc; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxBackupConfiguracaoDesc" ON pbx_backup_configuracao USING btree (cfg_descricao);


--
-- Name: idxBackupConfiguracaoId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxBackupConfiguracaoId" ON pbx_backup_configuracao USING btree (cfg_id);


--
-- Name: idxBackupFrequenciaFrqDescricao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxBackupFrequenciaFrqDescricao" ON pbx_backup_frequencia USING btree (frq_descricao);


--
-- Name: idxBackupFrequenciaQtdeQtDescricao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxBackupFrequenciaQtdeQtDescricao" ON pbx_backup_frequencia_qtde USING btree (qt_descricao);


--
-- Name: idxBilCalldate; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxBilCalldate" ON pbx_bilhetes USING btree (calldate);


--
-- Name: idxBilDst; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxBilDst" ON pbx_bilhetes USING btree (dst);


--
-- Name: idxBilSrc; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxBilSrc" ON pbx_bilhetes USING btree (src);


--
-- Name: idxBilUniqueidCalldate; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxBilUniqueidCalldate" ON pbx_bilhetes USING btree (calldate, uniqueid);


--
-- Name: idxBilhetesAccoutCode; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxBilhetesAccoutCode" ON ast_bilhetes USING btree (accountcode);


--
-- Name: idxBilhetesComplDirecao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxBilhetesComplDirecao" ON pbx_bilhetes_complemento USING btree (direcao);


--
-- Name: idxBilhetesComplUniqId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxBilhetesComplUniqId" ON pbx_bilhetes_complemento USING btree (uniqueid2);


--
-- Name: idxBilhetesComplUnqDir; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxBilhetesComplUnqDir" ON pbx_bilhetes_complemento USING btree (uniqueid2, direcao);


--
-- Name: idxBkpProtocoloDesc; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxBkpProtocoloDesc" ON pbx_backup_protocolo USING btree (prt_descricao);


--
-- Name: idxCampanha; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxCampanha" ON pbx_campanha_lista USING btree (cmp_id);


--
-- Name: idxClassificaRegIdBilhetes; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxClassificaRegIdBilhetes" ON pbx_classifica_reg USING btree (id_bilhetes);


--
-- Name: idxCmpList; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxCmpList" ON pbx_campanha_lista USING btree (cmp_id, list_id);


--
-- Name: idxConferenciaNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxConferenciaNumero" ON pbx_conferencia USING btree (numero);


--
-- Name: idxConsultaDDDprefixo; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxConsultaDDDprefixo" ON pbx_consulta_ddd USING btree (prefixo);


--
-- Name: idxConsultaDDDprefixoFaixa; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxConsultaDDDprefixoFaixa" ON pbx_consulta_ddd USING btree (prefixo, inicial, final);


--
-- Name: idxControleData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxControleData" ON pbx_controle_acesso USING btree (acs_data_ini);


--
-- Name: idxControleId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxControleId" ON pbx_controle_acesso USING btree (acs_id);


--
-- Name: idxControleProgUltAcess; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxControleProgUltAcess" ON pbx_controle_acesso USING btree (acs_prog_ultacess);


--
-- Name: idxControleUserId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxControleUserId" ON pbx_controle_acesso USING btree (acs_user_id);


--
-- Name: idxDgvNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxDgvNumero" ON pbx_dgv USING btree (numero);


--
-- Name: idxDisaNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxDisaNumero" ON pbx_disa USING btree (numero);


--
-- Name: idxEventosDacsAgtFila; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEventosDacsAgtFila" ON pbx_eventos_dacs USING btree (fila, agente);


--
-- Name: idxEvtAgtDac; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtAgtDac" ON pbx_eventos_agentes USING btree (id_dac);


--
-- Name: idxEvtAgtEntradaPausa; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtAgtEntradaPausa" ON pbx_eventos_agentes USING btree (entrada_pausa);


--
-- Name: idxEvtAgtLogin; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtAgtLogin" ON pbx_eventos_agentes USING btree (login);


--
-- Name: idxEvtAgtLogoff; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtAgtLogoff" ON pbx_eventos_agentes USING btree (logoff);


--
-- Name: idxEvtAgtMatricula; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtAgtMatricula" ON pbx_eventos_agentes USING btree (matricula);


--
-- Name: idxEvtAgtRelEvt; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtAgtRelEvt" ON pbx_eventos_agentes USING btree (relaciona_eventos);


--
-- Name: idxEvtAgtSaidaPausa; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtAgtSaidaPausa" ON pbx_eventos_agentes USING btree (saida_pausa);


--
-- Name: idxEvtDacAgtFila; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtDacAgtFila" ON ast_eventos_dacs USING btree (fila, agente);


--
-- Name: idxEvtDacsAgente; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtDacsAgente" ON pbx_eventos_dacs USING btree (agente);


--
-- Name: idxEvtDacsFila; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtDacsFila" ON pbx_eventos_dacs USING btree (fila);


--
-- Name: idxEvtLogLogffMat; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtLogLogffMat" ON pbx_eventos_agentes USING btree (matricula, login, logoff);


--
-- Name: idxEvtLoginDac; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxEvtLoginDac" ON pbx_eventos_agentes USING btree (login, id_dac);


--
-- Name: idxFilaSupAgentes; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxFilaSupAgentes" ON pbx_supervisor_dacs USING btree (dac);


--
-- Name: idxGrupoAudioRamal; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxGrupoAudioRamal" ON pbx_grupo_audio_ramal USING btree (gp_id);


--
-- Name: idxGruposNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxGruposNumero" ON pbx_grupos USING btree (numero);


--
-- Name: idxIaxPbxNome; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxIaxPbxNome" ON pbx_iax_pbx USING btree (nome);


--
-- Name: idxIntegracaoRegUid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxIntegracaoRegUid" ON pbx_integracao_reg USING btree (reg_uniqueid);


--
-- Name: idxMotivosPausasNome; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX "idxMotivosPausasNome" ON pbx_motivos_pausas USING btree (motivo);


--
-- Name: idxMunClassificaUdDddd; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "idxMunClassificaUdDddd" ON pbx_municipio_classifica USING btree (uf, mun_ddd);


--
-- Name: idxMunPrefixo; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "idxMunPrefixo" ON pbx_municipio_prefixo USING btree (prx_prefixo);


--
-- Name: idxMunPrefixoId; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "idxMunPrefixoId" ON pbx_municipio_prefixo USING btree (mun_id);


--
-- Name: idxPbxAbdsrDataNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxAbdsrDataNumero" ON pbx_abandonadas_semretorno USING btree (abdsr_data, abdsr_fila, abdsr_numero);


--
-- Name: idxPbxAbdsrUid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxAbdsrUid" ON pbx_abandonadas_semretorno USING btree (abdsr_uniqueid);


--
-- Name: idxPbxBackupConfiguracao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxPbxBackupConfiguracao" ON pbx_backup_configuracao USING btree (dst_id, tp_id, frq_id);


--
-- Name: idxPbxBilhetesDataBilhete; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxPbxBilhetesDataBilhete" ON pbx_bilhetes USING btree (data_bilhete);


--
-- Name: idxPbxCampanhaDescricao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxPbxCampanhaDescricao" ON pbx_campanha USING btree (cmp_descricao);


--
-- Name: idxPbxCampanhaOperacaoCLC; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxCampanhaOperacaoCLC" ON pbx_campanha_operacao USING btree (cmp_id, list_id, cont_id);


--
-- Name: idxPbxCampanhaOperacaoSelect; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxCampanhaOperacaoSelect" ON pbx_campanha_operacao USING btree (matricula, cmpo_data, cmpo_status);


--
-- Name: idxPbxCanaisChannel; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxCanaisChannel" ON pbx_canais USING btree (channel);


--
-- Name: idxPbxCanaisLink; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxCanaisLink" ON pbx_canais USING btree (link);


--
-- Name: idxPbxClientId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxClientId" ON pbx_cliente_audio USING btree (client_id);


--
-- Name: idxPbxClienteOutId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxClienteOutId" ON pbx_cliente USING btree (client_out_id);


--
-- Name: idxPbxClienteRefId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxClienteRefId" ON pbx_cliente USING btree (client_ref_id);


--
-- Name: idxPbxDacMatricula; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxDacMatricula" ON pbx_supervisor_agentes USING btree (dac, matricula);


--
-- Name: idxPbxLinkslink; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxLinkslink" ON pbx_links USING btree (link);


--
-- Name: idxPbxListanegraIdNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxListanegraIdNumero" ON pbx_listanegra USING btree (id, numero);


--
-- Name: idxPbxListanegraNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxListanegraNumero" ON pbx_listanegra USING btree (numero);


--
-- Name: idxPbxListanegraRotaId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxListanegraRotaId" ON pbx_listanegra_rota USING btree (id_rota);


--
-- Name: idxPbxLogFormsFileForm; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxLogFormsFileForm" ON pbx_log_forms USING btree (log_file_form);


--
-- Name: idxPbxLogFormsIdProg; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxLogFormsIdProg" ON pbx_log_forms USING btree (id_prog);


--
-- Name: idxPbxMunclasUfNome; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "idxPbxMunclasUfNome" ON pbx_municipio_classifica USING btree (uf, mun_nome);


--
-- Name: idxPbxProtocoloRegProtocolo; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxPbxProtocoloRegProtocolo" ON pbx_protocolo_reg USING btree (protocolo);


--
-- Name: idxPbxRenameNewname; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxRenameNewname" ON pbx_rename USING btree (newname);


--
-- Name: idxPbxRenameOldname; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxRenameOldname" ON pbx_rename USING btree (oldname);


--
-- Name: idxPbxRenameUniqueid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxRenameUniqueid" ON pbx_rename USING btree (uniqueid);


--
-- Name: idxPbxTarifContratoOperadoraTipo; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxPbxTarifContratoOperadoraTipo" ON pbx_tarif_contrato USING btree (oper_id, contr_numero);


--
-- Name: idxPbxTelevendasBloqueioData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasBloqueioData" ON pbx_televendas_bloqueio USING btree (tlvb_data);


--
-- Name: idxPbxTelevendasBloqueioDst; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasBloqueioDst" ON pbx_televendas_bloqueio USING btree (dst);


--
-- Name: idxPbxTelevendasBloqueioDstData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasBloqueioDstData" ON pbx_televendas_bloqueio USING btree (dst, tlvb_data);


--
-- Name: idxPbxTelevendasBloqueioMes; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasBloqueioMes" ON pbx_televendas_bloqueio USING btree (tlvb_mes);


--
-- Name: idxPbxTelevendasBloqueioSrc; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasBloqueioSrc" ON pbx_televendas_bloqueio USING btree (src);


--
-- Name: idxPbxTelevendasRegData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasRegData" ON pbx_televendas_reg USING btree (tlvb_data);


--
-- Name: idxPbxTelevendasRegDst; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasRegDst" ON pbx_televendas_reg USING btree (dst);


--
-- Name: idxPbxTelevendasRegDstData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasRegDstData" ON pbx_televendas_bloqueio USING btree (dst, tlvb_data);


--
-- Name: idxPbxTelevendasRegMes; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasRegMes" ON pbx_televendas_reg USING btree (tlvb_mes);


--
-- Name: idxPbxTelevendasRegSrc; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxTelevendasRegSrc" ON pbx_televendas_reg USING btree (src);


--
-- Name: idxPbxTroncosKhompGrupo; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxPbxTroncosKhompGrupo" ON pbx_troncos_khomp USING btree (grupo);


--
-- Name: idxPbxUid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxUid" ON pbx_cliente_audio USING btree (uid);


--
-- Name: idxPbxUraMovimentoData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxUraMovimentoData" ON pbx_ura_movimento USING btree (umv_data);


--
-- Name: idxPbxUraMovimentoUid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxUraMovimentoUid" ON pbx_ura_movimento USING btree (uniqueid);


--
-- Name: idxPbxUraMovimentoUidTp; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxUraMovimentoUidTp" ON pbx_ura_movimento USING btree (uniqueid, umv_tipo);


--
-- Name: idxPbxUraMovimentoUraId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPbxUraMovimentoUraId" ON pbx_ura_movimento USING btree (umv_ura_id);


--
-- Name: idxPeriodo; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxPeriodo" ON pbx_hora_dia USING btree (periodo);


--
-- Name: idxPortabilidadeTel; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxPortabilidadeTel" ON portabilidade USING btree (tel_doadora);


--
-- Name: idxQueueGruposNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxQueueGruposNumero" ON pbx_queues_grupos USING btree (numero);


--
-- Name: idxQueueNome; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxQueueNome" ON pbx_queues_grupos USING btree (nome);


--
-- Name: idxRamaisPbxNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxRamaisPbxNumero" ON pbx_ramais_pbx USING btree (numero);


--
-- Name: idxRelOrdenaRelColuna; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE UNIQUE INDEX "idxRelOrdenaRelColuna" ON pbx_relatorio_ordena USING btree (ord_rel_id, ord_nome_coluna);


--
-- Name: idxRotasSaidaModeloModelo; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxRotasSaidaModeloModelo" ON pbx_rotas_saida_modelos USING btree (modelo);


--
-- Name: idxSipRamaisNome; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxSipRamaisNome" ON pbx_sip_ramais USING btree (nome);


--
-- Name: idxSiteNome; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxSiteNome" ON pbx_sites USING btree (descricao);


--
-- Name: idxSupAgentesDac; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxSupAgentesDac" ON pbx_supervisor_agentes USING btree (dac);


--
-- Name: idxUid2Dacs; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxUid2Dacs" ON pbx_eventos_dacs USING btree (uid2);


--
-- Name: idxUidAgente; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxUidAgente" ON pbx_eventos_dacs USING btree (uid2, agente);


--
-- Name: idxUidAgenteEvt; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxUidAgenteEvt" ON pbx_eventos_dacs USING btree (uid2, agente, evento);


--
-- Name: idxUniqueBilhestes; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxUniqueBilhestes" ON pbx_bilhetes USING btree (uniqueid);


--
-- Name: idxUniqueProto; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxUniqueProto" ON pbx_protocolo_reg USING btree (uniqueid);


--
-- Name: idxUnqBase; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxUnqBase" ON pbx_sites USING btree (host, basedados);


--
-- Name: idxUsuariosApelido; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX "idxUsuariosApelido" ON pbx_usuarios USING btree (apelido);


--
-- Name: idxUsuariosGrupos; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "idxUsuariosGrupos" ON pbx_grupo_usuario USING btree (gp_id);


--
-- Name: idxVdsClassificacoesDataDia; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxVdsClassificacoesDataDia" ON vds_classificacoes USING btree (clas_data);


--
-- Name: idxVdsClassificacoesEmpData; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxVdsClassificacoesEmpData" ON vds_classificacoes USING btree (emp_id, clas_reg);


--
-- Name: idxVdsProtocolosEmpId; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxVdsProtocolosEmpId" ON vds_protcolos USING btree (emp_id);


--
-- Name: idxVdsProtocolosProtoParceiro; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxVdsProtocolosProtoParceiro" ON vds_protcolos USING btree (prt_proto_parceiro);


--
-- Name: idxVoicemailUsuariosCxPostal; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "idxVoicemailUsuariosCxPostal" ON pbx_voicemail_usuarios USING btree (caixa_postal);


--
-- Name: idxclasDDDUfddd; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "idxclasDDDUfddd" ON pbx_consulta_ddd USING btree (uf, codigo_ddd);


--
-- Name: idxpbxempresadepto; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX idxpbxempresadepto ON pbx_departamentos USING btree (nome_depto, empresa);


--
-- Name: idxpbxempresanome; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX idxpbxempresanome ON pbx_empresa USING btree (nome);


--
-- Name: idxpbxempresarazao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX idxpbxempresarazao ON pbx_empresa USING btree (razao_social);


--
-- Name: idxprefixos; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX idxprefixos ON prefixos USING btree (prefixo);


--
-- Name: idxprefixosrange; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX idxprefixosrange ON prefixos USING btree (prefixo, ini, fim);


--
-- Name: pbxBackupArquivosUniqueid; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbxBackupArquivosUniqueid" ON pbx_backup_arquivos USING btree (uniqueid);


--
-- Name: pbxBilhetesOnlineIdBilhetes; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "pbxBilhetesOnlineIdBilhetes" ON pbx_bilhetes_online USING btree (id_bilhetes);


--
-- Name: pbxListaNegraIdPai; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbxListaNegraIdPai" ON pbx_listanegra USING btree (id_pai);


--
-- Name: pbxMunicipiosCodigoDdd; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "pbxMunicipiosCodigoDdd" ON pbx_municipios USING btree (codigo_ddd);


--
-- Name: pbxMunicipiosNomeLocalidade; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "pbxMunicipiosNomeLocalidade" ON pbx_municipios USING btree (nome_localidade);


--
-- Name: pbxMunicipiosNomeMunicipio; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "pbxMunicipiosNomeMunicipio" ON pbx_municipios USING btree (nome_municipio);


--
-- Name: pbxMunicipiosPFiFf; Type: INDEX; Schema: public; Owner: simplesip; Tablespace: 
--

CREATE INDEX "pbxMunicipiosPFiFf" ON pbx_municipios USING btree (prefixo, faixa_inicial, faixa_final);


--
-- Name: pbxNaoPerturbeNumero; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbxNaoPerturbeNumero" ON pbx_nao_perturbe USING btree (numero);


--
-- Name: pbxProtoRegProtocolo; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "pbxProtoRegProtocolo" ON pbx_protocolo_reg USING btree (protocolo);


--
-- Name: pbxProtoRegProtoparceiro; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE INDEX "pbxProtoRegProtoparceiro" ON pbx_protocolo_reg USING btree (protoparceiro);


--
-- Name: pbx_backup_arquivos_arq_hash_uindex; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX pbx_backup_arquivos_arq_hash_uindex ON pbx_backup_arquivos USING btree (arq_hash);


--
-- Name: pbx_contextosAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_contextosAcaoOpcao" ON pbx_contextos USING btree (opcao, acao);


--
-- Name: pbx_contextos_opcoesAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_contextos_opcoesAcaoOpcao" ON pbx_contextos_opcoes USING btree (opcao, acao);


--
-- Name: pbx_disaAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_disaAcaoOpcao" ON pbx_disa USING btree (opcao, acao);


--
-- Name: pbx_gruposAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_gruposAcaoOpcao" ON pbx_grupos USING btree (opcao, acao);


--
-- Name: pbx_horariosAcaoNaoOpcaoNao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_horariosAcaoNaoOpcaoNao" ON pbx_horarios USING btree (opcao_nao, acao_nao);


--
-- Name: pbx_horarios_itensAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_horarios_itensAcaoOpcao" ON pbx_horarios_itens USING btree (opcao, acao);


--
-- Name: pbx_integracao_configuracaoAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_integracao_configuracaoAcaoOpcao" ON pbx_integracao_configuracao USING btree (opcao, acao);


--
-- Name: pbx_listanegraAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_listanegraAcaoOpcao" ON pbx_listanegra USING btree (opcao, acao);


--
-- Name: pbx_queues_gruposAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_queues_gruposAcaoOpcao" ON pbx_queues_grupos USING btree (opcao, acao);


--
-- Name: pbx_rotas_entradaAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_rotas_entradaAcaoOpcao" ON pbx_rotas_entrada USING btree (opcao, acao);


--
-- Name: pbx_supervisor_agentes_idx; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX pbx_supervisor_agentes_idx ON pbx_supervisor_agentes USING btree (matricula);


--
-- Name: pbx_uraAcaoOpcao; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE INDEX "pbx_uraAcaoOpcao" ON pbx_ura USING btree (opcao, acao);


--
-- Name: pbx_usuarios_matricula_key; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX pbx_usuarios_matricula_key ON pbx_usuarios USING btree (matricula);


--
-- Name: pkPbxTarifContratoPreco; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "pkPbxTarifContratoPreco" ON pbx_tarif_contrato_preco USING btree (contr_id, prc_vigencia, prc_tipo_opera);


--
-- Name: uniquePbxPesquisaMovimento; Type: INDEX; Schema: public; Owner: contacte; Tablespace: 
--

CREATE UNIQUE INDEX "uniquePbxPesquisaMovimento" ON pbx_pesquisa_movimento USING btree (pl_id, pp_id, pq_id, po_id, uniqueid);


--
-- Name: tg_atualiza_data_bilhete; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER tg_atualiza_data_bilhete
    BEFORE INSERT ON ast_bilhetes
    FOR EACH ROW
    EXECUTE PROCEDURE fn_atualiza_data_bilhete();


--
-- Name: tg_atualiza_vds_clas_data; Type: TRIGGER; Schema: public; Owner: contacte
--

CREATE TRIGGER tg_atualiza_vds_clas_data
    BEFORE INSERT ON vds_classificacoes
    FOR EACH ROW
    EXECUTE PROCEDURE fn_atualiza_vds_clas_data();


--
-- Name: tg_atuliza_saldo_franquia; Type: TRIGGER; Schema: public; Owner: contacte
--

CREATE TRIGGER tg_atuliza_saldo_franquia
    BEFORE INSERT ON pbx_tarif_franquia_movimento
    FOR EACH ROW
    EXECUTE PROCEDURE fn_atuliza_saldo_franquia();


--
-- Name: tg_atuliza_saldo_prepago; Type: TRIGGER; Schema: public; Owner: contacte
--

CREATE TRIGGER tg_atuliza_saldo_prepago
    AFTER INSERT ON pbx_prepago_movimento
    FOR EACH ROW
    EXECUTE PROCEDURE fn_atuliza_saldo_prepago();


--
-- Name: tg_franquia_alteracao; Type: TRIGGER; Schema: public; Owner: contacte
--

CREATE TRIGGER tg_franquia_alteracao
    BEFORE UPDATE ON pbx_tarif_franquia
    FOR EACH ROW
    EXECUTE PROCEDURE fn_franquia_alteracao();


--
-- Name: tg_franquia_inclusao; Type: TRIGGER; Schema: public; Owner: contacte
--

CREATE TRIGGER tg_franquia_inclusao
    BEFORE INSERT ON pbx_tarif_franquia
    FOR EACH ROW
    EXECUTE PROCEDURE fn_franquia_inclusao();


--
-- Name: RefpbxPrecoContridContratoContrId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_contrato_preco
    ADD CONSTRAINT "RefpbxPrecoContridContratoContrId" FOREIGN KEY (contr_id) REFERENCES pbx_tarif_contrato(contr_id);


--
-- Name: RefpbxTarifaContrPrecoPrcIdContratoPrecoPrcId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_registra
    ADD CONSTRAINT "RefpbxTarifaContrPrecoPrcIdContratoPrecoPrcId" FOREIGN KEY (prc_id) REFERENCES pbx_tarif_contrato_preco(prc_id);


--
-- Name: RefpbxTarifaRegistraContridContratoContrId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_registra
    ADD CONSTRAINT "RefpbxTarifaRegistraContridContratoContrId" FOREIGN KEY (contr_id) REFERENCES pbx_tarif_contrato(contr_id);


--
-- Name: RefpbxTarifaZeroContridContratoContrId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_contrato_tarifa_zero
    ADD CONSTRAINT "RefpbxTarifaZeroContridContratoContrId" FOREIGN KEY (contr_id) REFERENCES pbx_tarif_contrato(contr_id);


--
-- Name: Refpbx_empresas15; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_contrato
    ADD CONSTRAINT "Refpbx_empresas15" FOREIGN KEY (empresa) REFERENCES pbx_empresa(id);


--
-- Name: Refpbx_integracao_configuracao9; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_metodo
    ADD CONSTRAINT "Refpbx_integracao_configuracao9" FOREIGN KEY (itgc_id) REFERENCES pbx_integracao_configuracao(itgc_id);


--
-- Name: Refpbx_integracao_metodo6; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_parametro
    ADD CONSTRAINT "Refpbx_integracao_metodo6" FOREIGN KEY (itgm_id) REFERENCES pbx_integracao_metodo(itgm_id);


--
-- Name: Refpbx_integracao_protocolo4; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_configuracao
    ADD CONSTRAINT "Refpbx_integracao_protocolo4" FOREIGN KEY (itgp_id) REFERENCES pbx_integracao_protocolo(itgp_id);


--
-- Name: Refpbx_integracao_tipo2; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_protocolo
    ADD CONSTRAINT "Refpbx_integracao_tipo2" FOREIGN KEY (itgt_id) REFERENCES pbx_integracao_tipo(itgt_id);


--
-- Name: Refpbx_integracao_tipo3; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_integracao_configuracao
    ADD CONSTRAINT "Refpbx_integracao_tipo3" FOREIGN KEY (itgt_id) REFERENCES pbx_integracao_tipo(itgt_id);


--
-- Name: Refpbx_operadoras14; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_contrato
    ADD CONSTRAINT "Refpbx_operadoras14" FOREIGN KEY (oper_id) REFERENCES pbx_operadoras(oper_id);


--
-- Name: Refpbx_tarif_tipo_franquiaId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_tarif_contrato
    ADD CONSTRAINT "Refpbx_tarif_tipo_franquiaId" FOREIGN KEY (contr_tipo_franquia) REFERENCES pbx_tarif_tipo_franquia(tfq_id);


--
-- Name: fkBackupId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_arquivos
    ADD CONSTRAINT "fkBackupId" FOREIGN KEY (bkp_id) REFERENCES pbx_backup(bkp_id);


--
-- Name: fkBkConfigDstId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_configuracao
    ADD CONSTRAINT "fkBkConfigDstId" FOREIGN KEY (dst_id) REFERENCES pbx_backup_destino(dst_id);


--
-- Name: fkBkDstFrqId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_configuracao
    ADD CONSTRAINT "fkBkDstFrqId" FOREIGN KEY (frq_id) REFERENCES pbx_backup_frequencia(frq_id);


--
-- Name: fkBkDstTpId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_configuracao
    ADD CONSTRAINT "fkBkDstTpId" FOREIGN KEY (tp_id) REFERENCES pbx_backup_tipo(tp_id);


--
-- Name: fkBkpDstIdPrtId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_destino
    ADD CONSTRAINT "fkBkpDstIdPrtId" FOREIGN KEY (prt_id) REFERENCES pbx_backup_protocolo(prt_id);


--
-- Name: fkBkpIdCfgId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup
    ADD CONSTRAINT "fkBkpIdCfgId" FOREIGN KEY (cfg_id) REFERENCES pbx_backup_configuracao(cfg_id);


--
-- Name: fkBkpIdTpId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup
    ADD CONSTRAINT "fkBkpIdTpId" FOREIGN KEY (tp_id) REFERENCES pbx_backup_tipo(tp_id);


--
-- Name: fkFrqQtdeIdFrqId; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_backup_frequencia_qtde
    ADD CONSTRAINT "fkFrqQtdeIdFrqId" FOREIGN KEY (frq_id) REFERENCES pbx_backup_frequencia(frq_id);


--
-- Name: fkUsuarios; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY pbx_grupo_usuario
    ADD CONSTRAINT "fkUsuarios" FOREIGN KEY (user_id) REFERENCES pbx_usuarios(id);


--
-- Name: fk_pbx_campanha_contato_display_pbx_campanha_lista_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_contato_display
    ADD CONSTRAINT fk_pbx_campanha_contato_display_pbx_campanha_lista_1 FOREIGN KEY (list_id) REFERENCES pbx_campanha_lista(list_id);


--
-- Name: fk_pbx_campanha_contato_fone_pbx_campanha_contato_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_contato_fone
    ADD CONSTRAINT fk_pbx_campanha_contato_fone_pbx_campanha_contato_1 FOREIGN KEY (cont_id) REFERENCES pbx_campanha_contato(cont_id);


--
-- Name: fk_pbx_campanha_contato_pbx_campanha_lista_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_contato
    ADD CONSTRAINT fk_pbx_campanha_contato_pbx_campanha_lista_1 FOREIGN KEY (list_id) REFERENCES pbx_campanha_lista(list_id);


--
-- Name: fk_pbx_campanha_lista_pbx_campanha_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_lista
    ADD CONSTRAINT fk_pbx_campanha_lista_pbx_campanha_1 FOREIGN KEY (cmp_id) REFERENCES pbx_campanha(cmp_id);


--
-- Name: fk_pbx_campanha_pbx_campanha_status_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha
    ADD CONSTRAINT fk_pbx_campanha_pbx_campanha_status_1 FOREIGN KEY (cmp_status) REFERENCES pbx_campanha_status(cpst_id);


--
-- Name: fk_pbx_campanha_pbx_campanha_tipo_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha
    ADD CONSTRAINT fk_pbx_campanha_pbx_campanha_tipo_1 FOREIGN KEY (cmp_tipo_campanha) REFERENCES pbx_campanha_tipo(ctp_id);


--
-- Name: fk_pbx_campanha_usuarios_pbx_campanha_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_campanha_usuarios
    ADD CONSTRAINT fk_pbx_campanha_usuarios_pbx_campanha_1 FOREIGN KEY (cmp_id) REFERENCES pbx_campanha(cmp_id);


--
-- Name: fk_pbx_classifica_item_pbx_classifica_atendimento_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_classifica_item
    ADD CONSTRAINT fk_pbx_classifica_item_pbx_classifica_atendimento_1 FOREIGN KEY (clas_id) REFERENCES pbx_classifica_atendimento(clas_id);


--
-- Name: fk_pbx_cliente_anotacoes_pbx_cliente; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_anotacoes
    ADD CONSTRAINT fk_pbx_cliente_anotacoes_pbx_cliente FOREIGN KEY (client_id) REFERENCES pbx_cliente(client_id);


--
-- Name: fk_pbx_cliente_audio_pbx_cliente; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_audio
    ADD CONSTRAINT fk_pbx_cliente_audio_pbx_cliente FOREIGN KEY (client_id) REFERENCES pbx_cliente(client_id);


--
-- Name: fk_pbx_cliente_contato_pbx_cliente; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_contato
    ADD CONSTRAINT fk_pbx_cliente_contato_pbx_cliente FOREIGN KEY (client_id) REFERENCES pbx_cliente(client_id);


--
-- Name: fk_pbx_cliente_origem_pbx_cliente_fornecedor_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente_origem
    ADD CONSTRAINT fk_pbx_cliente_origem_pbx_cliente_fornecedor_1 FOREIGN KEY (cfr_id) REFERENCES pbx_cliente_fornecedor(cfr_id);


--
-- Name: fk_pbx_cliente_pbx_cliente_origem_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente
    ADD CONSTRAINT fk_pbx_cliente_pbx_cliente_origem_1 FOREIGN KEY (clo_id) REFERENCES pbx_cliente_origem(clo_id);


--
-- Name: fk_pbx_cliente_pbx_cliente_segmento_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_cliente
    ADD CONSTRAINT fk_pbx_cliente_pbx_cliente_segmento_1 FOREIGN KEY (csg_id) REFERENCES pbx_cliente_segmento(csg_id);


--
-- Name: fk_pbx_fornecedor_permissao_pbx_cliente_fornecedor_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_fornecedor_permissao
    ADD CONSTRAINT fk_pbx_fornecedor_permissao_pbx_cliente_fornecedor_1 FOREIGN KEY (cfr_id) REFERENCES pbx_cliente_fornecedor(cfr_id);


--
-- Name: fk_pbx_status_contato_campanha_pbx_campanha_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_status_contato_campanha
    ADD CONSTRAINT fk_pbx_status_contato_campanha_pbx_campanha_1 FOREIGN KEY (cmp_id) REFERENCES pbx_campanha(cmp_id);


--
-- Name: fk_pbx_status_contato_campanha_pbx_campanha_contato_status_1; Type: FK CONSTRAINT; Schema: public; Owner: contacte
--

ALTER TABLE ONLY pbx_status_contato_campanha
    ADD CONSTRAINT fk_pbx_status_contato_campanha_pbx_campanha_contato_status_1 FOREIGN KEY (ctst_id) REFERENCES pbx_campanha_contato_status(ctst_id);


--
-- Name: fk_usuarios; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY pbx_dac_usuario
    ADD CONSTRAINT fk_usuarios FOREIGN KEY (id_usuario) REFERENCES pbx_usuarios(id);


--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- Name: pabx_agentes; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_agentes FROM PUBLIC;
REVOKE ALL ON TABLE pabx_agentes FROM contacte;
GRANT ALL ON TABLE pabx_agentes TO contacte;


--
-- Name: pabx_agentes_eventos; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_agentes_eventos FROM PUBLIC;
REVOKE ALL ON TABLE pabx_agentes_eventos FROM contacte;
GRANT ALL ON TABLE pabx_agentes_eventos TO contacte;


--
-- Name: pabx_bilhetes; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_bilhetes FROM PUBLIC;
REVOKE ALL ON TABLE pabx_bilhetes FROM contacte;
GRANT ALL ON TABLE pabx_bilhetes TO contacte;


--
-- Name: pabx_bilhetes_complemento; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_bilhetes_complemento FROM PUBLIC;
REVOKE ALL ON TABLE pabx_bilhetes_complemento FROM contacte;
GRANT ALL ON TABLE pabx_bilhetes_complemento TO contacte;


--
-- Name: pabx_filas; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_filas FROM PUBLIC;
REVOKE ALL ON TABLE pabx_filas FROM contacte;
GRANT ALL ON TABLE pabx_filas TO contacte;


--
-- Name: pabx_pausas; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_pausas FROM PUBLIC;
REVOKE ALL ON TABLE pabx_pausas FROM contacte;
GRANT ALL ON TABLE pabx_pausas TO contacte;


--
-- Name: pabx_pesquisa; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_pesquisa FROM PUBLIC;
REVOKE ALL ON TABLE pabx_pesquisa FROM contacte;
GRANT ALL ON TABLE pabx_pesquisa TO contacte;


--
-- Name: pabx_pesquisa_liberacao; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_pesquisa_liberacao FROM PUBLIC;
REVOKE ALL ON TABLE pabx_pesquisa_liberacao FROM contacte;
GRANT ALL ON TABLE pabx_pesquisa_liberacao TO contacte;


--
-- Name: pabx_pesquisa_movimento; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_pesquisa_movimento FROM PUBLIC;
REVOKE ALL ON TABLE pabx_pesquisa_movimento FROM contacte;
GRANT ALL ON TABLE pabx_pesquisa_movimento TO contacte;


--
-- Name: pabx_pesquisa_opcoes; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_pesquisa_opcoes FROM PUBLIC;
REVOKE ALL ON TABLE pabx_pesquisa_opcoes FROM contacte;
GRANT ALL ON TABLE pabx_pesquisa_opcoes TO contacte;


--
-- Name: pabx_pesquisa_questoes; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_pesquisa_questoes FROM PUBLIC;
REVOKE ALL ON TABLE pabx_pesquisa_questoes FROM contacte;
GRANT ALL ON TABLE pabx_pesquisa_questoes TO contacte;


--
-- Name: pabx_ramais; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_ramais FROM PUBLIC;
REVOKE ALL ON TABLE pabx_ramais FROM contacte;
GRANT ALL ON TABLE pabx_ramais TO contacte;


--
-- Name: pabx_registra_classificacao; Type: ACL; Schema: public; Owner: contacte
--

REVOKE ALL ON TABLE pabx_registra_classificacao FROM PUBLIC;
REVOKE ALL ON TABLE pabx_registra_classificacao FROM contacte;
GRANT ALL ON TABLE pabx_registra_classificacao TO contacte;


--
-- Name: pbx_queues_grupos_mesa; Type: ACL; Schema: public; Owner: simplesip
--

REVOKE ALL ON TABLE pbx_queues_grupos_mesa FROM PUBLIC;
REVOKE ALL ON TABLE pbx_queues_grupos_mesa FROM simplesip;
GRANT ALL ON TABLE pbx_queues_grupos_mesa TO simplesip;
GRANT SELECT ON TABLE pbx_queues_grupos_mesa TO PUBLIC;


--
-- Name: vph_grupo_agenda; Type: ACL; Schema: public; Owner: simplesip
--

REVOKE ALL ON TABLE vph_grupo_agenda FROM PUBLIC;
REVOKE ALL ON TABLE vph_grupo_agenda FROM simplesip;
GRANT ALL ON TABLE vph_grupo_agenda TO simplesip;
GRANT ALL ON TABLE vph_grupo_agenda TO PUBLIC;


--
-- PostgreSQL database dump complete
--

