ALTER TABLE `chatbots` ADD `habilitar_nuevo_chat` ENUM('version_1','version_2','ambos') NOT NULL DEFAULT 'version_1' AFTER `ia_copilote_token`;
ALTER TABLE `bots` ADD `tiempo_sesion_bot` INT(3) NOT NULL DEFAULT '60' AFTER `mensaje_fuera_horario_transferir`;

CREATE TABLE etiquetas_conversaciones (
    id INT AUTO_INCREMENT PRIMARY KEY,
    id_chatbot INT NOT NULL,
    etiqueta_id INT NOT NULL,
    sesion VARCHAR(100) NOT NULL,
    fecha_sistema DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE etiquetas (
    id INT AUTO_INCREMENT PRIMARY KEY,
    id_chatbot INT NOT NULL,
    etiqueta VARCHAR(100) NOT NULL,
    color VARCHAR(50) NOT NULL,
    descripcion TEXT,
    fecha_sistema DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    activo INT(1) NOT NULL DEFAULT 0
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO modulos (id, nombreMenu, nombreModulo, padre, orden, padreId, activo, url, icono, created_at, updated_at) 
VALUES (58, 'message.menu_etiquetas', 'Menu Etiquetas', '0', '5', '0', '1', '', '<i class=\"fas fa-tag nav-icon\"></i>', '2024-05-01 00:00:00', '2024-05-01 00:00:00');

INSERT INTO modulos (id, nombreMenu, nombreModulo, padre, orden, padreId, activo, url, icono, created_at, updated_at) 
VALUES (59, 'message.menu_etiquetas', 'Etiquetas', '58', '5', '58', '1', 'etiquetas', '<i class=\"fas fa-tag nav-icon\"></i>', '2024-05-01 00:00:00', '2024-05-01 00:00:00');

INSERT INTO modulos (id, nombreMenu, nombreModulo, padre, orden, padreId, activo, url, icono, created_at, updated_at) 
VALUES (60, 'message.etiqueta_dashboard', 'Etiquetas Dashboard', '58', '6', '58', '1', 'etiquetas/dashboard', '<i class=\"fas fa-chart-line nav-icon\"></i>', '2024-05-01 00:00:00', '2024-05-01 00:00:00');

INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '59', 'etiquetas');
INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '59', 'etiquetas/{id}/edit');
INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '59', 'etiquetas/store');
INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '59', 'etiquetas/{id}');

INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '60', 'etiquetas/dashboard');
INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '60', 'etiquetas/conversaciones');
INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '60', 'etiquetas/datos-graficos');
INSERT INTO modulos_url (id, modulos_id, url) VALUES (NULL, '60', 'etiquetas/descargar-csv');


INSERT INTO `modulos` (`id`, `nombreMenu`, `nombreModulo`, `padre`, `orden`, `padreId`, `activo`, `url`, `icono`, `created_at`, `updated_at`) VALUES (61, 'message.menu_messenger', 'Messenger', '0', '4', '0', '1', 'messenger/connect', '<i class=\"nav-icon fas fa-comment\"></i>', '2020-08-05 01:06:36', '2020-08-05 01:55:21');
INSERT INTO `modulos_url` (`id`, `modulos_id`, `url`) VALUES (NULL, '61', 'messenger/login-url');
INSERT INTO `modulos_url` (`id`, `modulos_id`, `url`) VALUES (NULL, '61', 'messenger/connect');
INSERT INTO `modulos_url` (`id`, `modulos_id`, `url`) VALUES (NULL, '61', 'messenger/callback');
INSERT INTO `modulos_url` (`id`, `modulos_id`, `url`) VALUES (NULL, '61', 'desconectar-pagina/{id}');
INSERT INTO `modulos_url` (`id`, `modulos_id`, `url`) VALUES (NULL, '61', 'cambiar-estado-pagina/{id}');

ALTER TABLE `config_pages` ADD `rsocial` ENUM('facebook','instagram') NOT NULL DEFAULT 'facebook' AFTER `url`;
ALTER TABLE `message_input` ADD `mid` VARCHAR(255) NULL AFTER `intentos`;

ALTER TABLE `whatsapp_masivo_plantillas` ADD `ver_plantilla_users` VARCHAR(255) NULL AFTER `id_imagen_whatsapp_whatsapp`, ADD INDEX `ver_plantilla_users` (`ver_plantilla_users`);
INSERT INTO `modulos_url` (`id`, `modulos_id`, `url`) VALUES (NULL, '43', 'whatsapptemplate/verusuarios/{id}');
INSERT INTO `modulos_url` (`id`, `modulos_id`, `url`) VALUES (NULL, '43', 'whatsapptemplate/verusuarios');

