--- LIMPA BASE DE DADOS; ------ LIMPA BILHETES E SUAS RELACOES --------------------- truncate table ast_bilhetes; truncate table pbx_bilhetes; truncate table ast_eventos_dacs; truncate table pbx_eventos_dacs; truncate table ast_bilhetes_complemento; truncate table pbx_bilhetes_complemento; truncate table pbx_eventos_agentes; truncate table pbx_registra_classificacao; truncate table pbx_classifica_reg; truncate table "atualiza_routing"; truncate table "pbx_indisponivel_fila"; truncate table "md_atendimento"; truncate table "md_evento"; truncate table "md_message"; truncate table "md_supervisor"; truncate table "md_system_message"; truncate table "md_tipo"; truncate table "mkt_dados_anatel_scm"; truncate table "mkt_prospect"; truncate table "pbx_abandonadas_semretorno"; truncate table "pbx_abandonadas_status"; truncate table "pbx_administrador_funcoes"; truncate table "pbx_agenda"; truncate table "pbx_agenda_servidores"; truncate table "pbx_agendas"; truncate table "pbx_agente_funcoes"; truncate table "pbx_agents_usuarios"; truncate table "pbx_anotacoes"; truncate table "pbx_anuncios"; truncate table "pbx_arquivo_som"; truncate table "pbx_audita"; truncate table "pbx_audita_full"; truncate table "pbx_aviso_franquia_reg"; ----- MODULO BACKUP -------- -- select * FROM pbx_backup_arquivos; truncate table "pbx_backup_arquivos"; truncate table "pbx_backup" cascade; truncate table "pbx_backups"; truncate table "pbx_bilhetes"; truncate table "pbx_bilhetes_complemento"; truncate table "pbx_bilhetes_online"; truncate table "pbx_bilhetes_wpp"; truncate table "pbx_bloco_de_notas"; truncate table "pbx_cadastro_funcoes"; truncate table "pbx_callback"; truncate table "pbx_callback_numeros"; ------ tabelas de campanha -------- truncate table "pbx_campanha_contato_fone" cascade; truncate table "pbx_campanha_contato" cascade; truncate table "pbx_campanha_contato_display" cascade; truncate table "pbx_campanha_lista" cascade; truncate table "pbx_campanha_operacao" cascade; truncate table "pbx_campanha_referencia_recicla" cascade; truncate table "pbx_campanha_referencia_status" cascade; truncate table "pbx_campanha_registro" cascade; truncate table "pbx_campanha_template" cascade; truncate table "pbx_campanha_usuarios" cascade; truncate table "pbx_campanha" cascade; -- select * from pbx_campanha_contato_status order by 1; -- PRESERVA OS CONTATOS PADRAO PARA CAMPANHA. delete from "pbx_campanha_contato_status" where ctst_nome not in('NOVO','ATENDIDA','NÃO ATENDIDA','ELETRÔNICA','FICOU MUDO','OCUPADO','DESLIGOU'); truncate table "pbx_grupo_campanha_contato_status"; --- TABELAS DE CLASSIFICACAO DAS CHAMADAS ----- truncate table "pbx_classifica_item"; truncate table "pbx_classifica_atendimento" cascade; truncate table "pbx_classifica_dacs"; truncate table "pbx_classifica_reg"; truncate table "pbx_classifica_reg_wpp"; --- TABELAS DE PRE-VENDA ------ truncate table "pbx_cliente_anotacoes"; truncate table "pbx_cliente_audio"; truncate table "pbx_cliente_contato"; truncate table "pbx_fornecedor_permissao"; truncate table "pbx_cliente_referencia_vendedor"; truncate table "pbx_cliente" cascade; truncate table "pbx_cliente_origem" cascade; truncate table "pbx_cliente_fornecedor" cascade; truncate table "pbx_canais"; truncate table "pbx_cel"; truncate table "pbx_centro_custo"; truncate table "pbx_chamada_ramal"; truncate table "pbx_chefe_secretaria"; truncate table "pbx_conf_monitor"; truncate table "pbx_conferencia"; truncate table "pbx_config"; truncate table "pbx_contextos"; truncate table "pbx_contextos_canais"; truncate table "pbx_contextos_canais_tmp"; truncate table "pbx_contextos_modelos"; truncate table "pbx_contextos_modelos_tmp"; truncate table "pbx_contextos_opcoes"; truncate table "pbx_contextos_opcoes_tmp"; truncate table "pbx_contribuinte"; truncate table "pbx_controle_acesso"; truncate table "pbx_controle_acesso_item"; truncate table "pbx_cs_usuarios"; truncate table "pbx_cs_usuarios_ddd"; truncate table "pbx_dac_usuario"; truncate table "pbx_dahdi"; truncate table "pbx_dbtype"; truncate table "pbx_ddd"; truncate table "pbx_departamentos"; truncate table "pbx_dgv"; truncate table "pbx_disa"; truncate table "pbx_disa_numeros"; truncate table "pbx_eventos_agentes"; truncate table "pbx_eventos_agentes_wpp"; truncate table "pbx_eventos_dacs"; truncate table "pbx_eventos_dacs_wpp"; truncate table "pbx_eventos_transbordo"; truncate table "pbx_fila_audios"; truncate table "pbx_fila_grupos"; delete from "pbx_grupo" where upper(gp_nome) not in('SINCCONTASENHA', 'USER.API','SUPERVISOR','ADMINISTRADOR','AGENTE'); delete from "pbx_grupo_funcoes" where gp_id not in(select gp_id from pbx_grupo where upper(gp_nome) in('SINCCONTASENHA', 'USER.API','SUPERVISOR','ADMINISTRADOR','AGENTE')); delete from "pbx_motivos_pausas" where upper(motivo) not in('ACW','LOGIN', 'REUNIAO', 'PESSOAL', 'AUSENTE', 'RECUSADA', 'INTERVALO', 'TREINAMENTO', 'TOALETE', 'FEEDBACK', 'ATENDIMENTO', 'ALMOCO'); delete from "pbx_grupo_usuario" where user_id not in(select id from pbx_usuarios where lower(apelido) in('admin', 'administrador', 'sinccontasenha', 'user.api')); delete from "pbx_grupo_usuario" where gp_id not in(select gp_id from pbx_grupo where upper(gp_nome) in('SINCCONTASENHA', 'USER.API','SUPERVISOR','ADMINISTRADOR','AGENTE')); delete from "pbx_usuarios" where lower(apelido) not in('admin', 'administrador', 'sinccontasenha', 'user.api'); update pbx_usuarios set senha = md5('OitoDois80_SiP') where apelido = 'admin'; update pbx_usuarios set senha = md5('SimpleS_admin') where apelido = 'administrador'; update pbx_usuarios set senha = md5('s3ncC0nt@S2nh@') where apelido = 'sinccontasenha'; update pbx_usuarios set senha = md5('0000') where apelido = 'user.api'; truncate table "pbx_grupo_audio_ramal"; truncate table "pbx_grupo_revendas"; truncate table "pbx_grupo_ura_ramal"; truncate table "pbx_grupos"; truncate table "pbx_grupos_atendimento"; truncate table "pbx_grupos_atendimento_ramais"; truncate table "pbx_grupos_numeros"; truncate table "pbx_horarios"; truncate table "pbx_horarios_itens"; ---- TABELAS NECESSARIAS PARA O SISTEMA ---- -- select * from "mkt_regiao_estados"; -- select * from "operadoras"; -- select * from "pbx_agents_agents"; -- select * from "pbx_agents_general"; -- select * from "pbx_backup_configuracao"; -- select * from "pbx_backup_destino"; -- select * from "pbx_backup_frequencia"; -- select * from "pbx_backup_frequencia_qtde"; -- select * from "pbx_backup_protocolo"; -- select * from "pbx_backup_tipo"; -- select * from "pbx_campanha_parametros"; -- select * from "pbx_campanha_status"; -- select * from "pbx_campanha_tipo"; -- select * from "pbx_cliente_etapa"; -- select * from "pbx_cliente_segmento"; -- select * from "pbx_conf_padrao"; -- select * from "pbx_confmail"; -- select * from "pbx_consulta_ddd"; -- select * from "pbx_contextos_operacoes"; -- select * from "pbx_estrategia_distribuicao"; -- select * from "pbx_facilidades"; -- select * from "pbx_features_application"; -- select * from "pbx_features_featuremap"; -- select * from "pbx_features_general"; -- select * from "pbx_funcoes"; -- select * from "pbx_funcoes_internas"; -- select * from "pbx_hora_dia"; -- select * from "pbx_hora_meta"; -- select * from "pbx_iax_general"; -- select * from "pbx_integracao_tipo"; -- select * from "pbx_integracao_protocolo"; -- select * from "pbx_lista_negra_palavras"; -- select * from "pbx_municipio_classifica"; -- select * from "pbx_municipio_prefixo"; -- select * from "pbx_municipios"; -- select * from "pbx_musichold_grupos"; -- select * from "pbx_parametros"; -- select * from "pbx_operadoras"; -- select * from "pbx_pesquisa_questao_tipo"; -- select * from "pbx_sip_general"; -- select * from "pbx_status_ligacao"; -- select * from "pbx_status_retorno"; -- select * from "pbx_tab_ddd"; -- select * from "pbx_tarif_tipo_franquia"; -- select * from "pbx_tarifa_tipo_preco"; -- select * from "pbx_tempo_meta"; -- select * from "pbx_tipo_ligacao"; -- select * from "pbx_uf"; -- select * from "pbx_urls"; -- select * from "pbx_workflow_parametros"; -- select * from "pbx_voicemail_general"; -- select * from "prefixos"; -- select * from "pbx_digivoice_allportsconfig"; -- select * from "pbx_digivoice_e1config"; -- select * from "pbx_digivoice_general"; -- select * from "pbx_digivoice_grupos"; -- select * from "pbx_digivoice_grupos_"; -- select * from "pbx_digivoice_ramais_fxs"; ---- TABELAS NECESSARIAS PARA O SISTEMA ---- ---- TABELAS DESNECESSARIAS ------- drop table if exists "bilhetes_dupl"; drop table if exists "cdr"; drop table if exists "log_tarifa"; drop table if exists "pbx_grupo_bk"; drop table if exists "pbx_cliente_remover"; drop table if exists "pbx_teste"; drop table if exists "pbx_teste_permissao"; ---- /TABELAS DESNECESSARIAS ------- truncate table "pbx_iax_pbx"; truncate table "pbx_indisponivel"; --- TABELAS PARA CONFIGURACAO DA INTEGRACAO ATIVA ---- truncate table "pbx_integracao_agente_ativo"; truncate table "pbx_integracao_dados"; truncate table "pbx_integracao_metodo" cascade; truncate table "pbx_integracao_configuracao" cascade; truncate table "pbx_integracao_parametro"; truncate table "pbx_integracao_reg"; truncate table "pbx_khomp"; truncate table "pbx_kingdialer_bloqueios"; truncate table "pbx_kingdialer_campanha"; truncate table "pbx_kingdialer_config"; truncate table "pbx_ligueme_gratis"; truncate table "pbx_links"; truncate table "pbx_lista_discador"; truncate table "pbx_listanegra"; truncate table "pbx_listanegra_rota"; truncate table "pbx_log_forms"; truncate table "pbx_media_atendimento"; truncate table "pbx_media_atendimento_dia"; truncate table "pbx_message_wpp"; truncate table "pbx_monitor_evento"; truncate table "pbx_monitora_abdagi"; truncate table "pbx_monitora_sistema"; truncate table "pbx_monitoramento_ramais"; truncate table "pbx_nao_perturbe"; truncate table "pbx_nao_perturbe_cliente"; truncate table "pbx_nao_perturbe_controle"; truncate table "pbx_normaliza_agenda"; truncate table "pbx_notifica_media"; truncate table "pbx_operadora_rel"; truncate table "pbx_pausa_automatica"; truncate table "pbx_pausa_grupo_usuario"; truncate table "pbx_pbx_centro_custo_ramais"; truncate table "pbx_permissoes_discagem"; truncate table "pbx_pesquisa"; truncate table "pbx_pesquisa_liberacao"; truncate table "pbx_pesquisa_liberacao_dacs"; truncate table "pbx_pesquisa_log"; truncate table "pbx_pesquisa_movimento"; truncate table "pbx_pesquisa_opcoes"; truncate table "pbx_pesquisa_questoes"; truncate table "pbx_pesquisa_regitra"; truncate table "pbx_prepago_movimento"; truncate table "pbx_prioridades_atendimento"; truncate table "pbx_protocolo_reg"; truncate table "pbx_queues_general"; truncate table "pbx_queues_grupos"; truncate table "pbx_queues_membros"; truncate table "pbx_ramais_agenda"; truncate table "pbx_ramais_pbx"; truncate table "pbx_registra_classificacao"; truncate table "pbx_relatorio_filas"; truncate table "pbx_relatorio_ordena"; truncate table "pbx_relatorio_ordena_set"; truncate table "pbx_rename"; truncate table "pbx_replica"; truncate table "pbx_replica_host"; truncate table "pbx_replica_hosts"; truncate table "pbx_rotas_entrada"; truncate table "pbx_rotas_entrada_troncos"; truncate table "pbx_rotas_saida"; truncate table "pbx_rotas_saida_canais"; truncate table "pbx_rotas_saida_modelos"; truncate table "pbx_rotas_saida_ramais"; truncate table "pbx_sequencia"; truncate table "pbx_servers_sinc"; truncate table "pbx_servicos"; truncate table "pbx_servicos_registra"; truncate table "pbx_servicos_sistema"; truncate table "pbx_sip_ramais"; truncate table "pbx_sites"; truncate table "pbx_sms_send"; truncate table "pbx_status_contato_campanha"; truncate table "pbx_supervisor_agentes"; truncate table "pbx_supervisor_dacs"; truncate table "pbx_supervisor_funcoes"; truncate table "pbx_tabelas_check"; ---- TABELAS DE TARIFACAO ------- truncate table "pbx_tarif_contrato_tarifa_zero"; truncate table "pbx_tarif_registra"; truncate table "pbx_tarif_contrato_preco" cascade; truncate table "pbx_tarif_franquia"; truncate table "pbx_tarif_franquia_movimento"; truncate table "pbx_tarif_retarifa"; truncate table "pbx_tarifador_log"; truncate table "pbx_tarif_contrato" cascade; truncate table "pbx_empresa" cascade; truncate table "pbx_televendas_bloqueio"; truncate table "pbx_televendas_reg"; truncate table "pbx_troncos_dahdi"; truncate table "pbx_troncos_dgv"; truncate table "pbx_troncos_iax"; truncate table "pbx_troncos_khomp"; truncate table "pbx_troncos_sip"; truncate table "pbx_turnos"; truncate table "pbx_ura"; truncate table "pbx_ura_anuncio"; truncate table "pbx_ura_destino"; truncate table "pbx_ura_movimento"; truncate table "pbx_usuarios_senha"; truncate table "pbx_voicemail_usuarios"; truncate table "pbx_whatsapp_message"; truncate table "pbx_whatsapp_send"; truncate table "pbx_workflow_emails"; truncate table "pbx_workflow_emails_dacs"; truncate table "pbx_workflow_reg_envio"; truncate table "pbx_workflow_reg_envio_email"; truncate table "pbx_workflow_reg_envio_email_mensal"; truncate table "pbx_workflow_reg_envio_mensal"; truncate table "piperun"; truncate table "portabilidade"; truncate table "rma_departamentos"; truncate table "rma_depto_ramais"; truncate table "sip_dif_versao"; truncate table "sip_versao"; truncate table "sip_versao_arquivos"; truncate table "tb_lista_discador"; truncate table "tmp_modelos_incluidos"; truncate table "tmp_troncos_incluidos"; truncate table "vds_acompanha"; truncate table "vds_api_encotrado"; truncate table "vds_api_nao_encotrado"; truncate table "vds_chamadas"; truncate table "vds_chamadas_confere"; truncate table "vds_chamadas_diario"; truncate table "vds_classificacoes"; truncate table "vds_classificacoes_confere"; truncate table "vds_classificacoes_lista"; truncate table "vds_empresas"; truncate table "vds_grupos"; truncate table "vds_grupos_empresas"; truncate table "vds_log"; truncate table "vds_pesquisa"; truncate table "vds_pesquisa_log"; truncate table "vds_pesquisa_regitra"; truncate table "vds_protcolos"; truncate table "vds_protocolos_confere"; truncate table "vds_usuarios_confere"; truncate table "vds_vendedores"; truncate table "vph_contato_agenda"; truncate table "vph_grupo_agenda"; truncate table "vph_itens_contato";