<?php
#   SGT - The SGT for Internet - http://sgt.eti.br
#   Copyright (c) 2016-2018, Jean Azevedo. All rights reserved.

#   This file is part of SGT.

#   SGT is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   any later version.

#   SGT is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
    echo '<p>Iniciando Atualização do Banco de Dados!</p>';
    include "conectar.php";
    echo '<p>Conferindo verção do banco!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD f_url varchar(255) NOT NULL default '' AFTER ativo");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD f_url varchar(255) NOT NULL default '' AFTER ativo");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD f_url varchar(255) NOT NULL default '' AFTER ativo");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos DROP arq_e");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos DROP arq_tamanho_e");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos DROP arq_tipo_e");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos DROP arq_nome_e");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores DROP arq_m");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores DROP arq_tamanho_m");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores DROP arq_tipo_m");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores DROP arq_nome_m");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores DROP arq_c");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores DROP arq_tamanho_c");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores DROP arq_tipo_c");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores DROP arq_nome_c");
    $atu_db_sgt = $pdo_sgt->query("ALTER DATABASE db_sgt DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_chaves CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_e CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_hist CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_pro CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_key CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_local CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_log CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_marcas CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_modelos CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_comp CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_eqp CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_mon CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_offices CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_offices CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_pp CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_proc CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_ram_clok CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_setores CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_sistemas CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_switch CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipo_hd CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipos CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_videos CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_vlan CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_cap CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_pin CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_log CHANGE log log TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_hd_c` CHANGE `desc` `desc` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_hd_e` CHANGE `desc` `desc` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_pp CHANGE pp pp TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_switch` CHANGE `desc` `desc` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE desc_comp desc_comp TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos CHANGE desc_eqp desc_eqp TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Vamos Começar!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_pp` CHANGE COLUMN `desc` `descricao` VARCHAR(120) NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_hd_c` CHANGE COLUMN `desc` `descricao` TEXT NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_hd_e` CHANGE COLUMN `desc` `descricao` TEXT NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_key` CHANGE COLUMN `desc` `descricao` VARCHAR(80) NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_local` CHANGE COLUMN `desc` `descricao` VARCHAR(80) NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_map_canal` CHANGE COLUMN `desc` `descricao` VARCHAR(50) NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_map_ip` CHANGE COLUMN `desc` `descricao` VARCHAR(100) NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_switch` CHANGE COLUMN `desc` `descricao` TEXT NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE `tb_vlan` CHANGE COLUMN `desc` `descricao` VARCHAR(80) NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE usuario usuario VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE senha senha VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE nome nome VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE sobrenome sobrenome VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE email email VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_0 temp_0 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_1 temp_1 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_2 temp_2 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_3 temp_3 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_4 temp_4 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_5 temp_5 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_6 temp_6 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_7 temp_7 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_8 temp_8 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios CHANGE temp_9 temp_9 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_usuarios Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades CHANGE unidade unidade VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades CHANGE dominio dominio VARCHAR(60) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD nome_pt1 VARCHAR(80) NULL DEFAULT NULL AFTER ddd");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD email_pt1 VARCHAR(100) NULL DEFAULT NULL AFTER nome_pt1");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD nome_pt2 VARCHAR(80) NULL DEFAULT NULL AFTER email_pt1");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD email_pt2 VARCHAR(100) NULL DEFAULT NULL AFTER nome_pt2");
    echo '<p>Tabela tb_unidades Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_marcas CHANGE marca marca VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_modelos CHANGE modelo modelo VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_videos CHANGE modelo modelo VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_proc CHANGE proc proc VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_sistemas CHANGE sistema sistema VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipos CHANGE tipo tipo VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_offices CHANGE office office VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipo_hd CHANGE tipo tipo VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_eqp CHANGE user_nome user_nome VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_eqp CHANGE des des TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_comp CHANGE user_nome user_nome VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_comp CHANGE des des TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_mon CHANGE user_nome user_nome VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_mon CHANGE des des TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos CHANGE nserie nserie VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos CHANGE loja loja VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos CHANGE nnota nnota VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos CHANGE nptri nptri VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE nserie nserie VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE pmae pmae VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE desc_hd desc_hd VARCHAR(120) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE loja loja VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE nnota nnota INT(40) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE nptri nptri VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE nlacre nlacre INT(20) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE netbios netbios VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores CHANGE nserie nserie VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores CHANGE loja loja VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores CHANGE nnota nnota VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores CHANGE nptri nptri VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD setor INT(6) NULL DEFAULT NULL AFTER unidade");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD desc_mon TEXT NOT NULL AFTER nptri");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_log CHANGE ip ip VARCHAR(260) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_log CHANGE user_nome user_nome VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip CHANGE rede rede VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip CHANGE descricao descricao VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_local CHANGE local local VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_local CHANGE descricao descricao VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal CHANGE descricao descricao VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_vlan CHANGE vlan vlan VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_vlan CHANGE descricao descricao VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CHANGE nome_c nome_c VARCHAR(90) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CHANGE tel_d tel_d VARCHAR(2) NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CHANGE tel_p tel_p VARCHAR(4) NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CHANGE tel_u tel_u VARCHAR(4) NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CHANGE cel_d cel_d VARCHAR(2) NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CHANGE cel_p cel_p VARCHAR(5) NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios CHANGE cel_u cel_u VARCHAR(4) NOT NULL");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip CHANGE ts ts VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip CHANGE info info VARCHAR(90) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_pin CHANGE pin pin VARCHAR(10) NOT NULL");
    echo '<p>Tabela tb_marcas Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip CHANGE tel_d tel_d VARCHAR(2) NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip CHANGE tel_p tel_p VARCHAR(4) NOT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip CHANGE tel_u tel_u VARCHAR(4) NOT NULL");
    echo '<p>Tabela tb_voip Atualizada!</p>';
    $query=$pdo_sgt->prepare("DELETE FROM tb_conf WHERE conf=:conf");
    $query->bindValue(":conf","email-patri");
    $query->execute();
    echo '<p>Tabela tb_conf Atualizada!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_chaves ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_conf ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_e ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_hist ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_pro ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_key ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_local ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_log ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_marcas ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_modelos ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_comp ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_eqp ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_mon ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_offices ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_pp ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_proc ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_ram_clok ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_setores ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_sistemas ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_switch ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipo_hd ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipos ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_videos ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_vlan ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_cap ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_pin ENGINE = INNODB");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE proc proc INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE ram_clok ram_clok INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE tipo_hd tipo_hd INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE setor setor INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE sistema sistema INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE sistema sistema INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE office office INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE plc_video plc_video INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE cod_mon1 cod_mon1 INT(6) NULL DEFAULT NULL");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores CHANGE cod_mon2 cod_mon2 INT(6) NULL DEFAULT NULL");
    echo '<p>Configuraçoes do banco Atualizadas!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_cod_c (cod_c ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_tipo (tipo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_modelo (modelo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_setor (setor ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_mac_c (mac_c ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_mac_w (mac_w ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_cod_c (cod_c ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_tipo (tipo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_modelo (modelo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_setor (setor ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_mac_c (mac_c ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD INDEX idx_comp_mac_w (mac_w ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_usuario (usuario ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_nome (nome ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_sobrenome (sobrenome ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_email (email ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_unid_temp (unid_temp ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_nivel (nivel ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD INDEX idx_usuario_avancado (avancado ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD INDEX idx_unidade_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD INDEX idx_unidade_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD INDEX idx_unidade_ddd (ddd ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD INDEX idx_unidade_nome_pt1 (nome_pt1 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD INDEX idx_unidade_nome_pt2 (nome_pt2 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD INDEX idx_unidade_email_pt1 (email_pt1 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_unidades ADD INDEX idx_unidade_email_pt2 (email_pt2 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_marcas ADD INDEX idx_marca_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_marcas ADD INDEX idx_marca_marca (marca ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_modelos ADD INDEX idx_modelo_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_modelos ADD INDEX idx_modelo_modelo (modelo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_videos ADD INDEX idx_video_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_videos ADD INDEX idx_video_modelo (modelo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_videos ADD INDEX idx_video_des_vid (des_vid ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_proc ADD INDEX idx_proc_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_proc ADD INDEX idx_proc_proc (proc ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_proc ADD INDEX idx_proc_des_proc (des_proc ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_sistemas ADD INDEX idx_sistema_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_sistemas ADD INDEX idx_sistema_sistema (sistema ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipos ADD INDEX idx_tipo_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipos ADD INDEX idx_tipo_tipo (tipo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_offices ADD INDEX idx_office_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_offices ADD INDEX idx_office_office (office ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_ram_clok ADD INDEX idx_ram_clok_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_ram_clok ADD INDEX idx_ram_clok_clok (clok ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipo_hd ADD INDEX idx_tipo_hd_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_tipo_hd ADD INDEX idx_tipo_hd_tipo (tipo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD INDEX idx_eqp_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD INDEX idx_eqp_cod_e (cod_e ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD INDEX idx_eqp_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD INDEX idx_eqp_tipo (tipo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD INDEX idx_eqp_modelo (modelo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD INDEX idx_eqp_setor (setor ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD INDEX idx_eqp_mac_1 (mac_1 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD INDEX idx_mon_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD INDEX idx_mon_cod_m (cod_m ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD INDEX idx_mon_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD INDEX idx_mon_modelo (modelo ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD INDEX idx_mon_setor (setor ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip ADD INDEX idx_map_ip_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip ADD INDEX idx_map_ip_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip ADD INDEX idx_map_ip_ip (ip ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip ADD INDEX idx_map_ip_mac (mac ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_local ADD INDEX idx_local_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_local ADD INDEX idx_local_local (local ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal ADD INDEX idx_map_canal_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal ADD INDEX idx_map_canal_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal ADD INDEX idx_map_canal_local (local ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_vlan ADD INDEX idx_vlan_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_vlan ADD INDEX idx_vlan_vlan (vlan ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_setores ADD INDEX idx_setor_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_setores ADD INDEX idx_setor_setor (setor ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD INDEX idx_func_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD INDEX idx_func_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD INDEX idx_func_setor (setor ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD INDEX idx_func_p_nome (p_nome ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD INDEX idx_func_u_nome (u_nome ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD INDEX idx_func_nome_c (nome_c ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD INDEX idx_voip_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD INDEX idx_voip_unidade (unidade ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD INDEX idx_voip_setor (setor ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD INDEX idx_voip_voip (voip ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_cap ADD INDEX idx_voip_cap_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_cap ADD INDEX idx_voip_cap_grup (grup ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_pin ADD INDEX idx_voip_pin_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_pin ADD INDEX idx_voip_pin_spin (pin ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ADD INDEX idx_hd_c_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ADD INDEX idx_hd_c_de (de ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ADD INDEX idx_hd_c_para (para ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ADD INDEX idx_hd_c_status (status ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_e ADD INDEX idx_hd_e_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_e ADD INDEX idx_hd_e_cha (cha ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_hist ADD INDEX idx_hd_hist_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_hist ADD INDEX idx_hd_hist_cha (cha ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_pro ADD INDEX idx_hd_pro_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_pro ADD INDEX idx_hd_pro_produto (produto ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_conf ADD INDEX idx_conf_id (id ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_conf ADD INDEX idx_conf_conf (conf ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_conf ADD INDEX idx_conf_var1 (var1 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_conf ADD INDEX idx_conf_var2 (var2 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_conf ADD INDEX idx_conf_var3 (var3 ASC)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_conf ADD INDEX idx_conf_var4 (var4 ASC)");
    echo '<p>Index Criados Atualizadas!</p>';
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD CONSTRAINT fk_usuario_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_usuarios ADD CONSTRAINT fk_usuario_unid_temp FOREIGN KEY (unid_temp) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_modelos ADD CONSTRAINT fk_modelo_marca FOREIGN KEY (marca) REFERENCES tb_marcas (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_videos ADD CONSTRAINT fk_video_marca FOREIGN KEY (marca) REFERENCES tb_marcas (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_proc ADD CONSTRAINT fk_proc_marca FOREIGN KEY (marca) REFERENCES tb_marcas (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_tipo FOREIGN KEY (tipo) REFERENCES tb_tipos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_modelo FOREIGN KEY (modelo) REFERENCES tb_modelos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_proc FOREIGN KEY (proc) REFERENCES tb_proc (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_ram_clok FOREIGN KEY (ram_clok) REFERENCES tb_ram_clok (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_tipo_hd FOREIGN KEY (tipo_hd) REFERENCES tb_tipo_hd (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_setor FOREIGN KEY (setor) REFERENCES tb_setores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_sistema FOREIGN KEY (sistema) REFERENCES tb_sistemas (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_office FOREIGN KEY (office) REFERENCES tb_offices (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_plc_video FOREIGN KEY (plc_video) REFERENCES tb_videos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_cod_mon1 FOREIGN KEY (cod_mon1) REFERENCES tb_monitores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_computadores ADD CONSTRAINT fk_comp_cod_mon2 FOREIGN KEY (cod_mon2) REFERENCES tb_monitores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD CONSTRAINT fk_eqp_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD CONSTRAINT fk_eqp_tipo FOREIGN KEY (tipo) REFERENCES tb_tipos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD CONSTRAINT fk_eqp_setor FOREIGN KEY (setor) REFERENCES tb_setores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_equipamentos ADD CONSTRAINT fk_eqp_modelo FOREIGN KEY (modelo) REFERENCES tb_modelos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD CONSTRAINT fk_mom_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD CONSTRAINT fk_mom_tipo FOREIGN KEY (tipo) REFERENCES tb_tipos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD CONSTRAINT fk_mom_setor FOREIGN KEY (setor) REFERENCES tb_setores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_monitores ADD CONSTRAINT fk_mom_modelo FOREIGN KEY (modelo) REFERENCES tb_modelos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_eqp ADD CONSTRAINT fk_oc_eqp_cod_e FOREIGN KEY (cod_e) REFERENCES tb_equipamentos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_comp ADD CONSTRAINT fk_oc_comp_cod_c FOREIGN KEY (cod_c) REFERENCES tb_computadores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_oc_mon ADD CONSTRAINT fk_oc_mon_cod_m FOREIGN KEY (cod_m) REFERENCES tb_monitores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_log ADD CONSTRAINT fk_log_user_id FOREIGN KEY (user_id) REFERENCES tb_usuarios (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_ip ADD CONSTRAINT fk_mapa_ip_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal ADD CONSTRAINT fk_map_canal_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_map_canal ADD CONSTRAINT fk_map_canal_local FOREIGN KEY (local) REFERENCES tb_local (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_switch ADD CONSTRAINT fk_switch_local FOREIGN KEY (local) REFERENCES tb_local (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_switch ADD CONSTRAINT fk_switch_vlan FOREIGN KEY (vlan) REFERENCES tb_vlan (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD CONSTRAINT fk_funcionario_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_funcionarios ADD CONSTRAINT fk_funcionario_setor FOREIGN KEY (setor) REFERENCES tb_setores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD CONSTRAINT fk_voip_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD CONSTRAINT fk_voip_setor FOREIGN KEY (setor) REFERENCES tb_setores (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD CONSTRAINT fk_voip_ta_voip FOREIGN KEY (ta) REFERENCES tb_voip (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD CONSTRAINT fk_voip_voip_cap FOREIGN KEY (grup) REFERENCES tb_voip_cap (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD CONSTRAINT fk_voip_eqp FOREIGN KEY (eqp) REFERENCES tb_equipamentos (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip ADD CONSTRAINT fk_voip_func FOREIGN KEY (func) REFERENCES tb_funcionarios (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_cap ADD CONSTRAINT fk_voip_cap_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_pin ADD CONSTRAINT fk_voip_pin_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_voip_pin ADD CONSTRAINT fk_voip_pin_func FOREIGN KEY (func) REFERENCES tb_funcionarios (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_chaves ADD CONSTRAINT fk_chave_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_key ADD CONSTRAINT fk_key_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_pp ADD CONSTRAINT fk_pp_unidade FOREIGN KEY (unidade) REFERENCES tb_unidades (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ADD CONSTRAINT fk_hd_c_de FOREIGN KEY (de) REFERENCES tb_usuarios (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ADD CONSTRAINT fk_hd_c_para FOREIGN KEY (para) REFERENCES tb_usuarios (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_c ADD CONSTRAINT fk_hd_c_produto FOREIGN KEY (produto) REFERENCES tb_hd_pro (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_e ADD CONSTRAINT fk_hd_e_chamado FOREIGN KEY (cha) REFERENCES tb_hd_c (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_e ADD CONSTRAINT fk_hd_e_de FOREIGN KEY (de) REFERENCES tb_usuarios (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_hist ADD CONSTRAINT fk_hd_hist_chamado FOREIGN KEY (cha) REFERENCES tb_hd_c (id)");
    $atu_db_sgt = $pdo_sgt->query("ALTER TABLE tb_hd_hist ADD CONSTRAINT fk_hd_hist_de FOREIGN KEY (de) REFERENCES tb_usuarios (id)");
    echo '<p>Relações Criadas Atualizadas!</p>'
    . '<p><p/>'
    . '<p>Clique <a href="update_key.php">AQUI</a> para atualizar as senhas.<p/>'
    . '<p><p/>'
    . '<p>Banco de Dados Atualizado!</p>'   
        .'<a href="index.php">Ir para a página de login!</a>';
?>