CREATE TABLE IF NOT EXISTS `call_logs` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `session_id` VARCHAR(36) NOT NULL UNIQUE,
  `ride_id` VARCHAR(255) NOT NULL,
  `driver_id` VARCHAR(255) NOT NULL,
  `passenger_id` VARCHAR(255) NOT NULL,
  `driver_ip` VARCHAR(45) NULL DEFAULT NULL,
  `passenger_ip` VARCHAR(45) NULL DEFAULT NULL,
  `driver_conn_ip` VARCHAR(45) NULL DEFAULT NULL,
  `passenger_conn_ip` VARCHAR(45) NULL DEFAULT NULL,
  `status` VARCHAR(50) NOT NULL DEFAULT 'created', -- 'created', 'active', 'ended'
  `initiated_by` VARCHAR(255) NULL DEFAULT NULL,
  `end_reason` VARCHAR(255) NULL DEFAULT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `connected_at` TIMESTAMP NULL DEFAULT NULL,
  `ended_at` TIMESTAMP NULL DEFAULT NULL,
  INDEX `idx_session_id` (`session_id`),
  INDEX `idx_ride_id` (`ride_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
