-- Crear tabla para almacenar datos telemáticos desglosados
CREATE TABLE `webhook_telematic_data` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `vehicle_id` VARCHAR(50) NOT NULL,
  `license_plate` VARCHAR(50),
  `driver_id` VARCHAR(50),
  `co_driver_id` VARCHAR(50),
  `driver_name` VARCHAR(100),
  `co_driver_name` VARCHAR(100),
  `speed` INT,
  `latitude` DECIMAL(10,8),
  `longitude` DECIMAL(11,8),
  `direction` DECIMAL(5,2),
  `timestamp` DATETIME,
  `is_valid_gps` BOOLEAN,
  `is_ignition_on` BOOLEAN,
  `is_stopped` BOOLEAN,
  `has_no_power` BOOLEAN,
  `chronometer` DECIMAL(10,2),
  `odometer_gps` DECIMAL(15,6),
  `odometer_canbus` DECIMAL(15,2),
  `has_invalid_movement` BOOLEAN,
  `received_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;