--
-- Host: localhost    Database: italvettools_bdcrm
-- ------------------------------------------------------


--
-- Table structure for table `audit_logs`
--

CREATE TABLE `audit_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `action` varchar(100) NOT NULL,
  `entity_type` varchar(100) NOT NULL,
  `entity_id` int(11) DEFAULT NULL,
  `old_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`old_values`)),
  `new_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`new_values`)),
  `ip_address` varchar(45) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_audit_logs_entity` (`entity_type`,`entity_id`),
  KEY `idx_audit_logs_user_id` (`user_id`),
  KEY `idx_audit_logs_created_at` (`created_at`),
  CONSTRAINT `audit_logs_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `audit_logs`
--


--
-- Table structure for table `backups`
--

CREATE TABLE `backups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `file_name` varchar(300) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `type` enum('completo','parcial') NOT NULL DEFAULT 'completo',
  `size_bytes` bigint(20) DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `backups_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `backups`
--

INSERT INTO `backups` VALUES
(1,'backup_20260624_092138.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_092138.sql','completo',33103,1,'2026-06-24 15:21:40');

--
-- Table structure for table `event_users`
--

CREATE TABLE `event_users` (
  `event_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`event_id`,`user_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `event_users_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `event_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `event_users`
--

INSERT INTO `event_users` VALUES
(6,2),
(7,4);

--
-- Table structure for table `events`
--

CREATE TABLE `events` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `location` varchar(300) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `events`
--

INSERT INTO `events` VALUES
(1,'Feria QA Editada','Actualizado','2026-08-15','2026-08-20','Lima','active','2026-06-16 05:52:24','2026-06-16 05:52:33'),
(2,'Congreso QA',NULL,NULL,NULL,'Arequipa','active','2026-06-16 05:52:25','2026-06-16 05:52:25'),
(3,'Feria QA',NULL,NULL,NULL,NULL,'active','2026-06-17 02:59:38','2026-06-17 02:59:38'),
(4,'Test',NULL,NULL,NULL,NULL,'active','2026-06-17 03:01:14','2026-06-17 03:01:14'),
(6,'Evento Gestor',NULL,NULL,NULL,NULL,'active','2026-06-18 04:15:25','2026-06-18 04:15:25'),
(7,'APROHPERU 2026','Feria principal','2026-08-15','2026-08-20','Lima','active','2026-06-18 05:04:53','2026-06-18 05:04:53');

--
-- Table structure for table `lead_products`
--

CREATE TABLE `lead_products` (
  `lead_id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`lead_id`,`product_id`),
  KEY `product_id` (`product_id`),
  CONSTRAINT `lead_products_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lead_products_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lead_products`
--


--
-- Table structure for table `lead_status_history`
--

CREATE TABLE `lead_status_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `previous_status` varchar(30) DEFAULT NULL,
  `new_status` varchar(30) NOT NULL,
  `loss_reason_id` int(11) DEFAULT NULL,
  `notes` varchar(500) DEFAULT NULL,
  `changed_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `lead_id` (`lead_id`),
  KEY `loss_reason_id` (`loss_reason_id`),
  KEY `changed_by` (`changed_by`),
  CONSTRAINT `lead_status_history_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lead_status_history_ibfk_2` FOREIGN KEY (`loss_reason_id`) REFERENCES `loss_reasons` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lead_status_history_ibfk_3` FOREIGN KEY (`changed_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lead_status_history`
--

INSERT INTO `lead_status_history` VALUES
(1,1,'nuevo','contactado',NULL,'Primer contacto',1,'2026-06-17 02:59:56'),
(2,1,'contactado','calificado',NULL,NULL,1,'2026-06-17 02:59:58'),
(3,1,'calificado','ganado',NULL,'Cerrado!',1,'2026-06-17 03:00:00'),
(4,2,'nuevo','propuesta',NULL,NULL,1,'2026-06-17 03:00:02'),
(5,2,'propuesta','negociacion',NULL,NULL,1,'2026-06-17 03:00:04'),
(6,4,'nuevo','contactado',NULL,NULL,1,'2026-06-17 03:01:20'),
(9,23,'nuevo','contactado',NULL,NULL,4,'2026-06-23 04:37:21');

--
-- Table structure for table `lead_technical_profiles`
--

CREATE TABLE `lead_technical_profiles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `animal_type` varchar(100) DEFAULT NULL,
  `herd_size` varchar(100) DEFAULT NULL,
  `current_supplier` varchar(200) DEFAULT NULL,
  `interest_area` varchar(200) DEFAULT NULL,
  `additional_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`additional_data`)),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `lead_id` (`lead_id`),
  CONSTRAINT `lead_technical_profiles_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lead_technical_profiles`
--

INSERT INTO `lead_technical_profiles` VALUES
(2,23,'Prueba','100','Prueba','Prueba',NULL,'2026-06-23 03:43:40','2026-06-23 04:44:20');

--
-- Table structure for table `leads`
--

CREATE TABLE `leads` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `event_id` int(11) NOT NULL,
  `first_name` varchar(150) NOT NULL,
  `last_name` varchar(150) NOT NULL,
  `email` varchar(200) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `company` varchar(200) DEFAULT NULL,
  `position` varchar(200) DEFAULT NULL,
  `city` varchar(150) DEFAULT NULL,
  `region` varchar(150) DEFAULT NULL,
  `client_type` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`client_type`)),
  `industry` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`industry`)),
  `classification` varchar(20) DEFAULT NULL,
  `observations` text DEFAULT NULL,
  `source` enum('manual','scan','voice') NOT NULL DEFAULT 'manual',
  `status` enum('nuevo','contactado','calificado','propuesta','negociacion','ganado','perdido') NOT NULL DEFAULT 'nuevo',
  `loss_reason_id` int(11) DEFAULT NULL,
  `is_duplicate` tinyint(1) NOT NULL DEFAULT 0,
  `duplicate_of` int(11) DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `loss_reason_id` (`loss_reason_id`),
  KEY `duplicate_of` (`duplicate_of`),
  KEY `updated_by` (`updated_by`),
  KEY `idx_leads_event_id` (`event_id`),
  KEY `idx_leads_status` (`status`),
  KEY `idx_leads_created_by` (`created_by`),
  KEY `idx_leads_email` (`email`),
  KEY `idx_leads_phone` (`phone`),
  CONSTRAINT `leads_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `leads_ibfk_2` FOREIGN KEY (`loss_reason_id`) REFERENCES `loss_reasons` (`id`) ON DELETE SET NULL,
  CONSTRAINT `leads_ibfk_3` FOREIGN KEY (`duplicate_of`) REFERENCES `leads` (`id`) ON DELETE SET NULL,
  CONSTRAINT `leads_ibfk_4` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  CONSTRAINT `leads_ibfk_5` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `leads`
--

INSERT INTO `leads` VALUES
(1,3,'Carlos Editado','Gomez','carlos@test.com','5550001','AgroMex 2.0','Gerente',NULL,NULL,NULL,NULL,NULL,NULL,'manual','ganado',NULL,0,NULL,1,1,'2026-06-17 02:59:42','2026-06-17 03:00:00'),
(2,3,'Maria','Lopez','maria@test.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','negociacion',NULL,0,NULL,1,1,'2026-06-17 02:59:44','2026-06-17 03:00:04'),
(3,3,'Copia','Gomez','carlos@test.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,1,1,1,NULL,'2026-06-17 02:59:45','2026-06-17 02:59:45'),
(4,4,'T','L',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','contactado',NULL,0,NULL,1,1,'2026-06-17 03:01:18','2026-06-17 03:01:20'),
(10,7,'Sin nombre','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:36:54','2026-06-18 05:36:54'),
(11,7,'Sin nombre','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:37:33','2026-06-18 05:37:33'),
(12,7,'Sin nombre','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:42:30','2026-06-18 05:42:30'),
(13,7,'Brad','Delacruz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:46:27','2026-06-18 05:46:27'),
(14,7,'Hola','Esto',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:48:26','2026-06-18 05:48:26'),
(15,7,'Brian','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:48:45','2026-06-18 05:48:45'),
(16,7,'Carlos','De',NULL,NULL,'Agromex',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:50:45','2026-06-18 05:50:45'),
(17,7,'Sin nombre','Por voz',NULL,'55 50 2320',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:51:05','2026-06-18 05:51:05'),
(18,7,'Brian','Trabaja',NULL,NULL,'Agromex Mi Teléfono Es Nueve Veinte Uno Tres Cuatro Cuatro Tres Ocho',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:53:16','2026-06-18 05:53:16'),
(19,7,'Brian','Trabajo',NULL,'940 123 4056','Cruz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 06:00:36','2026-06-18 06:00:36'),
(20,7,'Brian','Trabajador',NULL,'920 123456','Cruz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 06:02:12','2026-06-18 06:02:12'),
(22,7,'Brian','De',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-19 20:10:08','2026-06-19 20:10:08'),
(23,7,'Bryan','De la cruz','bdelacruz654@gmail.com','+51947394676','Agromex','Gerente','chincha','Ica','[\"Distribuidor\"]','[\"Nutrici\\u00f3n Animal\"]','caliente','sssssss','manual','contactado',NULL,1,NULL,4,4,'2026-06-23 03:43:40','2026-06-23 04:37:21');

--
-- Table structure for table `loss_reasons`
--

CREATE TABLE `loss_reasons` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `loss_reasons`
--

INSERT INTO `loss_reasons` VALUES
(1,'Precio','El lead considero que el precio era muy alto','active','2026-06-17 03:03:47'),
(2,'Competencia','El lead eligio un competidor','active','2026-06-17 03:03:47'),
(3,'Sin interes','El lead perdio interes','active','2026-06-17 03:03:47'),
(4,'No contactable','No fue posible contactar al lead','active','2026-06-17 03:03:47'),
(5,'Presupuesto','El lead no cuenta con presupuesto','active','2026-06-17 03:03:47'),
(6,'Otro','Otro motivo no especificado','active','2026-06-17 03:03:47'),
(7,'Precio','El lead consideró que el precio era muy alto','active','2026-06-24 15:17:26'),
(8,'Competencia','El lead eligió un competidor','active','2026-06-24 15:17:26'),
(9,'Sin interés','El lead perdió interés en el producto/servicio','active','2026-06-24 15:17:26'),
(10,'No contactable','No fue posible contactar al lead','active','2026-06-24 15:17:26'),
(11,'Presupuesto','El lead no cuenta con presupuesto','active','2026-06-24 15:17:26'),
(12,'Otro','Otro motivo no especificado','active','2026-06-24 15:17:26');

--
-- Table structure for table `notes`
--

CREATE TABLE `notes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `type` enum('texto','audio') NOT NULL DEFAULT 'texto',
  `content` text DEFAULT NULL,
  `audio_file_path` varchar(500) DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `lead_id` (`lead_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `notes_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `notes_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `notes`
--


--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `type` enum('tarea_proxima','tarea_vencida','nuevo_lead','invitacion','actividad') NOT NULL,
  `title` varchar(200) NOT NULL,
  `message` text DEFAULT NULL,
  `reference_type` varchar(100) DEFAULT NULL,
  `reference_id` int(11) DEFAULT NULL,
  `is_read` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_notifications_user` (`user_id`,`is_read`),
  CONSTRAINT `notifications_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `notifications`
--


--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `category` varchar(150) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` VALUES
(1,'v2','Upd','Nutricion','active','2026-06-17 03:14:40','2026-06-17 03:14:48');

--
-- Table structure for table `tasks`
--

CREATE TABLE `tasks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `type` enum('llamada','reunion','correo','whatsapp','seguimiento','otro') NOT NULL,
  `scheduled_date` date NOT NULL,
  `scheduled_time` time DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `assigned_to` int(11) NOT NULL,
  `status` enum('pendiente','completada','cancelada') NOT NULL DEFAULT 'pendiente',
  `completed_at` timestamp NULL DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `lead_id` (`lead_id`),
  KEY `created_by` (`created_by`),
  KEY `idx_tasks_assigned_to` (`assigned_to`),
  KEY `idx_tasks_scheduled_date` (`scheduled_date`),
  KEY `idx_tasks_status` (`status`),
  CONSTRAINT `tasks_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `tasks_ibfk_2` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`),
  CONSTRAINT `tasks_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `tasks`
--

INSERT INTO `tasks` VALUES
(1,23,'llamada','2026-06-23','00:00:00','ssssssss',4,'pendiente',NULL,4,'2026-06-23 05:03:03','2026-06-23 05:03:03');

--
-- Table structure for table `technical_materials`
--

CREATE TABLE `technical_materials` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `type` enum('pdf','video') NOT NULL,
  `file_path` varchar(500) DEFAULT NULL,
  `external_url` varchar(500) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `technical_materials_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `technical_materials`
--

INSERT INTO `technical_materials` VALUES
(1,'Guia v2','Manual','pdf',NULL,'https://e.com/g.pdf','active',1,'2026-06-17 03:41:25','2026-06-17 03:41:31');

--
-- Table structure for table `whatsapp_templates`
--

CREATE TABLE `whatsapp_templates` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `content` text NOT NULL,
  `variables` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`variables`)),
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `whatsapp_templates_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `whatsapp_templates`
--

INSERT INTO `whatsapp_templates` VALUES
(1,'Saludo v2','Hola {nombre}!','[\"nombre\"]','active',1,'2026-06-17 04:36:04','2026-06-17 04:36:08');


