CREATE TABLE IF NOT EXISTS `apitude_activities_bookings` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `reference` VARCHAR(64) NOT NULL,
  `client_reference` VARCHAR(64) DEFAULT NULL,
  `status` VARCHAR(32) NOT NULL DEFAULT 'PENDING',
  `environment` VARCHAR(16) NOT NULL DEFAULT 'test',
  `currency` VARCHAR(8) DEFAULT NULL,
  `total_amount` DECIMAL(12,2) DEFAULT NULL,
  `total_net` DECIMAL(12,2) DEFAULT NULL,
  `pending_amount` DECIMAL(12,2) DEFAULT NULL,
  `holder_name` VARCHAR(128) DEFAULT NULL,
  `holder_surname` VARCHAR(128) DEFAULT NULL,
  `holder_email` VARCHAR(190) DEFAULT NULL,
  `holder_telephone` VARCHAR(64) DEFAULT NULL,
  `holder_country` VARCHAR(64) DEFAULT NULL,
  `holder_zip` VARCHAR(32) DEFAULT NULL,
  `holder_address` VARCHAR(255) DEFAULT NULL,
  `language` VARCHAR(8) DEFAULT 'en',
  `activity_code` VARCHAR(64) DEFAULT NULL,
  `activity_name` VARCHAR(255) DEFAULT NULL,
  `modality_code` VARCHAR(64) DEFAULT NULL,
  `modality_name` VARCHAR(255) DEFAULT NULL,
  `destination_code` VARCHAR(16) DEFAULT NULL,
  `destination_name` VARCHAR(128) DEFAULT NULL,
  `date_from` DATE DEFAULT NULL,
  `date_to` DATE DEFAULT NULL,
  `rate_key` VARCHAR(255) DEFAULT NULL,
  `pax_count` SMALLINT UNSIGNED DEFAULT 0,
  `adults` SMALLINT UNSIGNED DEFAULT 0,
  `children` SMALLINT UNSIGNED DEFAULT 0,
  `pax_distribution` TEXT DEFAULT NULL,
  `questions` TEXT DEFAULT NULL,
  `answers` TEXT DEFAULT NULL,
  `vouchers` TEXT DEFAULT NULL,
  `request_payload` LONGTEXT DEFAULT NULL,
  `response_payload` LONGTEXT DEFAULT NULL,
  `cancellation_policies` TEXT DEFAULT NULL,
  `cancellation_amount` DECIMAL(12,2) DEFAULT NULL,
  `cancellation_date` DATETIME DEFAULT NULL,
  `creation_date` DATETIME DEFAULT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_reference` (`reference`),
  KEY `idx_status` (`status`),
  KEY `idx_holder_email` (`holder_email`),
  KEY `idx_destination` (`destination_code`),
  KEY `idx_creation` (`creation_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
