-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `limozxdb`
--

-- --------------------------------------------------------

--
-- Table structure for table `activities`
--

CREATE TABLE `activities` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `customer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` enum('note','follow_up','task','reminder','resolution') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'note',
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `priority` enum('low','medium','high') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'medium',
  `due_date` timestamp NULL DEFAULT NULL,
  `status` enum('open','in_progress','completed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `tags` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `activities`
--

INSERT INTO `activities` (`id`, `tenant_id`, `customer_id`, `customer_name`, `type`, `title`, `content`, `priority`, `due_date`, `status`, `tags`, `created_by`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 'Amit Menon', 'follow_up', 'cxzcxzcx', 'cxzcxzc xc xcxzcxzc', 'medium', '2026-02-16 15:21:00', 'open', '[]', 28, '2026-02-16 09:52:31', '2026-02-16 09:52:31'),
(2, 1, 3, 'Isha Gupta', 'reminder', 'fdsfsdf', 'fdsf ds fds fds fdsfdsf', 'medium', '2026-02-16 15:32:00', 'open', '[]', 28, '2026-02-16 10:02:43', '2026-02-16 10:02:43');

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_leads`
--

CREATE TABLE `affiliate_leads` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `affiliate_id` bigint(20) UNSIGNED NOT NULL,
  `source_type` varchar(50) DEFAULT NULL,
  `customer_name` varchar(255) DEFAULT NULL,
  `customer_email` varchar(255) DEFAULT NULL,
  `customer_phone` varchar(20) DEFAULT NULL,
  `status` enum('new','contacted','qualified','converted','lost') NOT NULL DEFAULT 'new',
  `converted_booking_id` bigint(20) UNSIGNED DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

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

CREATE TABLE `audit_logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `entity_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `entity_id` bigint(20) UNSIGNED DEFAULT NULL,
  `old_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `new_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('success','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'success',
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `bids`
--

CREATE TABLE `bids` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `rfq_id` bigint(20) UNSIGNED NOT NULL,
  `bid_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `bidder_type` enum('operator','affiliate') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bidder_id` bigint(20) UNSIGNED NOT NULL,
  `proposed_rate` decimal(12,2) DEFAULT NULL,
  `total_proposed_cost` decimal(12,2) DEFAULT NULL,
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `vehicle_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `availability_dates` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `special_offers` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `terms_conditions` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('draft','submitted','under_review','accepted','rejected','withdrawn') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `rating` decimal(3,2) DEFAULT NULL,
  `review_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `submitted_at` timestamp NULL DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `reviewed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `bid_attachments`
--

CREATE TABLE `bid_attachments` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `bid_id` bigint(20) UNSIGNED NOT NULL,
  `file_name` varchar(255) DEFAULT NULL,
  `file_url` varchar(500) DEFAULT NULL,
  `file_type` varchar(50) DEFAULT NULL,
  `file_size` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `bookings`
--

CREATE TABLE `bookings` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `booking_number` varchar(50) NOT NULL,
  `passenger_id` bigint(20) UNSIGNED DEFAULT NULL,
  `driver_id` bigint(20) UNSIGNED DEFAULT NULL,
  `vehicle_id` bigint(20) UNSIGNED DEFAULT NULL,
  `operator_id` bigint(20) UNSIGNED DEFAULT NULL,
  `pickup_address` varchar(500) NOT NULL,
  `pickup_latitude` decimal(10,8) DEFAULT NULL,
  `pickup_longitude` decimal(11,8) DEFAULT NULL,
  `dropoff_address` varchar(500) NOT NULL,
  `dropoff_latitude` decimal(10,8) DEFAULT NULL,
  `dropoff_longitude` decimal(11,8) DEFAULT NULL,
  `scheduled_at` timestamp NULL DEFAULT NULL,
  `status` enum('pending','confirmed','driver_assigned','in_progress','completed','canceled','no_show') NOT NULL DEFAULT 'pending',
  `trip_type` enum('economy','comfort','premium','shared') NOT NULL DEFAULT 'economy',
  `estimated_distance` decimal(10,2) DEFAULT NULL,
  `estimated_duration_minutes` int(11) DEFAULT NULL,
  `estimated_fare` decimal(10,2) DEFAULT NULL,
  `actual_distance` decimal(10,2) DEFAULT NULL,
  `actual_duration_minutes` int(11) DEFAULT NULL,
  `final_fare` decimal(10,2) DEFAULT NULL,
  `surge_multiplier` decimal(3,2) NOT NULL DEFAULT 1.00,
  `discount_amount` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  `tip_amount` decimal(10,2) DEFAULT NULL,
  `payment_status` enum('pending','paid','failed','refunded') NOT NULL DEFAULT 'pending',
  `payment_method` varchar(50) DEFAULT NULL,
  `special_requests` text DEFAULT NULL,
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `bookings`
--

INSERT INTO `bookings` (`id`, `tenant_id`, `booking_number`, `passenger_id`, `driver_id`, `vehicle_id`, `operator_id`, `pickup_address`, `pickup_latitude`, `pickup_longitude`, `dropoff_address`, `dropoff_latitude`, `dropoff_longitude`, `scheduled_at`, `status`, `trip_type`, `estimated_distance`, `estimated_duration_minutes`, `estimated_fare`, `actual_distance`, `actual_duration_minutes`, `final_fare`, `surge_multiplier`, `discount_amount`, `tax_amount`, `tip_amount`, `payment_status`, `payment_method`, `special_requests`, `started_at`, `completed_at`, `created_at`, `updated_at`) VALUES
(1, 1, 'BK20260215001', NULL, 3, NULL, NULL, 'Durgapur Railway Station, Railway Ground Rail Colony, Durgapur, West Bengal, India', 23.49431730, 87.31772850, 'Netaji Subhash Chandra Bose International Airport (CCU), Airport Service Rd, International Airport, Dum Dum, Kolkata, West Bengal, India', 22.65356400, 88.44508470, '2026-02-15 08:03:00', 'confirmed', 'economy', 168.10, 180, 2931.50, NULL, NULL, NULL, 1.00, 0.00, 0.00, NULL, 'pending', 'cash', NULL, NULL, NULL, '2026-02-15 13:34:49', '2026-03-03 13:06:10'),
(3, 1, 'BK20260215002', 37, 2, NULL, NULL, 'Delhi cantt railway Junction, Kirby Place, Delhi Cantonment, New Delhi, Delhi, India', 28.61090260, 77.11494720, 'Shimla Railway Station, Cart Road, Nabha, Shimla, Himachal Pradesh, India', 31.10248600, 77.15979600, '2026-02-15 08:18:00', 'completed', 'economy', 353.10, 429, 6204.50, NULL, NULL, 3500.00, 1.00, 0.00, 0.00, NULL, 'pending', 'cash', NULL, NULL, '2026-02-16 05:55:22', '2026-02-15 14:00:14', '2026-02-16 05:55:22'),
(4, 1, 'BK20260215003', 37, 2, NULL, NULL, 'Delhi cantt railway Junction, Kirby Place, Delhi Cantonment, New Delhi, Delhi, India', 28.61090260, 77.11494720, 'Shimla Railway Station, Cart Road, Nabha, Shimla, Himachal Pradesh, India', 31.10248600, 77.15979600, '2026-02-15 08:18:00', 'completed', 'economy', 353.10, 429, 6204.50, NULL, NULL, 3500.00, 1.00, 0.00, 0.00, NULL, 'pending', 'cash', NULL, NULL, '2026-02-16 05:55:22', '2026-02-15 14:03:04', '2026-02-16 05:55:22'),
(5, 1, 'BK20260216001', 39, 3, NULL, NULL, 'Durgapur Railway Station, Railway Ground Rail Colony, Durgapur, West Bengal, India', 23.49431730, 87.31772850, 'Kempegowda International Airport Bengaluru (BLR), Karnataka, India', 13.19890900, 77.70689260, '2026-02-16 02:21:00', 'in_progress', 'economy', 1904.00, 2031, 32672.00, NULL, NULL, NULL, 1.00, 0.00, 0.00, NULL, 'pending', 'cash', NULL, NULL, NULL, '2026-02-16 07:54:27', '2026-03-03 12:51:37'),
(6, 1, 'BK20260217001', 38, 2, NULL, NULL, 'Durgapur Sub Divisional Hospital, Bidhannagar, Durgapur, West Bengal, India', 23.52603630, 87.34213130, 'Prayagraj Railway Station Gate Number 4, Leader Road, Miurabad, Prayagraj, Uttar Pradesh, India', 25.44528850, 81.82480570, '2026-02-17 06:45:00', 'pending', 'economy', 630.40, 737, 10980.00, NULL, NULL, NULL, 1.00, 0.00, 0.00, NULL, 'pending', 'cash', NULL, NULL, NULL, '2026-02-17 12:17:00', '2026-02-17 12:17:00');

-- --------------------------------------------------------

--
-- Table structure for table `booking_approvals`
--

CREATE TABLE `booking_approvals` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `booking_id` bigint(20) UNSIGNED NOT NULL,
  `corporate_traveler_id` bigint(20) UNSIGNED NOT NULL,
  `approver_id` bigint(20) UNSIGNED NOT NULL,
  `status` enum('pending','approved','rejected','commented') NOT NULL DEFAULT 'pending',
  `comments` text DEFAULT NULL,
  `requested_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `responded_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `commissions`
--

CREATE TABLE `commissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `booking_id` bigint(20) UNSIGNED NOT NULL,
  `commission_type` enum('driver','operator','affiliate','platform') NOT NULL,
  `recipient_id` bigint(20) UNSIGNED NOT NULL,
  `rate_percentage` decimal(5,2) DEFAULT NULL,
  `booking_amount` decimal(12,2) DEFAULT NULL,
  `commission_amount` decimal(12,2) DEFAULT NULL,
  `payout_id` bigint(20) UNSIGNED DEFAULT NULL,
  `status` enum('pending','paid','pending_review') NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `communication_logs`
--

CREATE TABLE `communication_logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `customer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `customer_name` varchar(255) NOT NULL,
  `channel` enum('call','sms','email','whatsapp','in_app_chat') NOT NULL DEFAULT 'in_app_chat',
  `direction` enum('incoming','outgoing') NOT NULL DEFAULT 'incoming',
  `duration` int(11) DEFAULT NULL,
  `message_preview` longtext NOT NULL,
  `timestamp` timestamp NULL DEFAULT NULL,
  `agent` varchar(255) DEFAULT NULL,
  `sentiment` enum('positive','neutral','negative') NOT NULL DEFAULT 'neutral',
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `compliance_checks`
--

CREATE TABLE `compliance_checks` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `check_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `last_check_date` date DEFAULT NULL,
  `next_check_date` date DEFAULT NULL,
  `status` enum('compliant','warning','non_compliant') NOT NULL DEFAULT 'compliant',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `corporate_accounts`
--

CREATE TABLE `corporate_accounts` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `company_registration_number` varchar(100) DEFAULT NULL,
  `tax_id` varchar(100) DEFAULT NULL,
  `industry` varchar(100) DEFAULT NULL,
  `company_size` varchar(50) DEFAULT NULL,
  `address` varchar(500) DEFAULT NULL,
  `city` varchar(100) DEFAULT NULL,
  `state` varchar(100) DEFAULT NULL,
  `country` varchar(100) DEFAULT NULL,
  `postal_code` varchar(20) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `website` varchar(255) DEFAULT NULL,
  `status` enum('active','inactive','pending_approval','suspended') NOT NULL DEFAULT 'pending_approval',
  `account_manager_id` bigint(20) UNSIGNED DEFAULT NULL,
  `total_employees` int(11) NOT NULL DEFAULT 0,
  `total_travelers` int(11) NOT NULL DEFAULT 0,
  `monthly_budget` decimal(12,2) DEFAULT NULL,
  `contract_start_date` date DEFAULT NULL,
  `contract_end_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `corporate_accounts`
--

INSERT INTO `corporate_accounts` (`id`, `tenant_id`, `user_id`, `company_name`, `company_registration_number`, `tax_id`, `industry`, `company_size`, `address`, `city`, `state`, `country`, `postal_code`, `phone`, `website`, `status`, `account_manager_id`, `total_employees`, `total_travelers`, `monthly_budget`, `contract_start_date`, `contract_end_date`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 'Default Account', NULL, NULL, 'Transportation', NULL, '123 Main St', 'New York', 'NY', 'USA', NULL, '+1-555-0100', 'https://example.com', 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-16 13:18:20', '2026-02-16 13:18:20'),
(2, 1, 2, 'Test Corporate Inc.', NULL, NULL, 'Transportation', NULL, '456 Business Ave', 'New York', 'NY', 'USA', '10002', '+1-555-1234', 'https://testcorp.com', 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-16 13:56:15', '2026-02-16 13:56:15'),
(3, 1, 2, 'Test Corporate Inc.', NULL, NULL, 'Transportation', NULL, '456 Business Ave', 'New York', 'NY', 'USA', '10002', '+1-555-1234', 'https://testcorp.com', 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-16 13:56:36', '2026-02-16 13:56:36'),
(4, 1, 2, 'Test Corporate Inc.', NULL, NULL, 'Transportation', NULL, '456 Business Ave', 'New York', 'NY', 'USA', '10002', '+1-555-1234', 'https://testcorp.com', 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-16 13:57:34', '2026-02-16 13:57:34'),
(5, 1, 2, 'Test Corporate Inc.', NULL, NULL, 'Transportation', NULL, '456 Business Ave', 'New York', 'NY', 'USA', '10002', '+1-555-1234', 'https://testcorp.com', 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-16 13:57:58', '2026-02-16 13:57:58'),
(6, 1, 2, 'Test Corporate Inc. 1771270095', NULL, NULL, 'Transportation', NULL, '456 Business Ave', 'New York', 'NY', 'USA', '10002', '+1-555-1234', 'https://testcorp.com', 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-16 13:58:15', '2026-02-16 13:58:15'),
(7, 1, 28, 'Test Company 2026-02-17 10:47:27', NULL, NULL, 'Technology', NULL, '123 Business St', 'San Francisco', 'CA', 'USA', '94105', '+1-555-0100', 'https://testcorp.com', 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-17 04:17:28', '2026-02-17 04:17:28'),
(8, 2, 1, 'Default Account - VelocityTech 351', NULL, NULL, 'General', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-17 05:55:25', '2026-02-17 05:55:25'),
(9, 3, 1, 'Default Account - QuantumEdge 521', NULL, NULL, 'General', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'active', NULL, 0, 0, NULL, NULL, NULL, '2026-02-17 05:55:25', '2026-02-17 05:55:25');

-- --------------------------------------------------------

--
-- Table structure for table `corporate_clients`
--

CREATE TABLE `corporate_clients` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `corporate_account_id` bigint(20) UNSIGNED NOT NULL,
  `client_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `client_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_company` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_position` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `loyalty_tier` enum('bronze','silver','gold','platinum') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'bronze',
  `total_trips` int(11) NOT NULL DEFAULT 0,
  `total_spent` decimal(12,2) NOT NULL DEFAULT 0.00,
  `last_trip_date` date DEFAULT NULL,
  `preferences` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `corporate_travelers`
--

CREATE TABLE `corporate_travelers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `corporate_account_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `employee_id` varchar(50) DEFAULT NULL,
  `department` varchar(100) DEFAULT NULL,
  `job_title` varchar(100) DEFAULT NULL,
  `manager_id` bigint(20) UNSIGNED DEFAULT NULL,
  `cost_center` varchar(100) DEFAULT NULL,
  `spending_limit` decimal(12,2) DEFAULT NULL,
  `status` enum('active','inactive','on_leave') NOT NULL DEFAULT 'active',
  `total_trips` int(11) NOT NULL DEFAULT 0,
  `total_spent` decimal(12,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `crm_contracts`
--

CREATE TABLE `crm_contracts` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `contract_number` varchar(50) NOT NULL,
  `quote_id` bigint(20) UNSIGNED NOT NULL,
  `corporate_account_id` bigint(20) UNSIGNED NOT NULL,
  `contract_value` decimal(12,2) DEFAULT NULL,
  `currency` varchar(3) NOT NULL DEFAULT 'USD',
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `sla_uptime_percentage` decimal(5,2) DEFAULT NULL,
  `sla_response_time_minutes` int(11) DEFAULT NULL,
  `sla_resolution_time_hours` int(11) DEFAULT NULL,
  `penalty_per_violation` decimal(12,2) DEFAULT NULL,
  `renewal_auto` tinyint(1) NOT NULL DEFAULT 1,
  `renewal_notice_days` int(11) NOT NULL DEFAULT 30,
  `cancellation_terms` text DEFAULT NULL,
  `status` enum('draft','pending_signature','active','expired','terminated','suspended') NOT NULL DEFAULT 'draft',
  `signed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `signature_date` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `crm_contracts`
--

INSERT INTO `crm_contracts` (`id`, `tenant_id`, `contract_number`, `quote_id`, `corporate_account_id`, `contract_value`, `currency`, `start_date`, `end_date`, `sla_uptime_percentage`, `sla_response_time_minutes`, `sla_resolution_time_hours`, `penalty_per_violation`, `renewal_auto`, `renewal_notice_days`, `cancellation_terms`, `status`, `signed_by`, `signature_date`, `created_at`, `updated_at`) VALUES
(1, 1, 'CONTRACT-20260216185611-410', 1, 1, 7000.00, 'USD', '2026-02-16', '2026-02-28', NULL, NULL, NULL, NULL, 0, 30, NULL, 'draft', 28, NULL, '2026-02-16 13:26:11', '2026-02-16 13:26:11'),
(2, 1, 'CONTRACT-20260216190242-498', 2, 1, 8000.00, 'USD', '2026-02-16', '2026-02-27', NULL, NULL, NULL, NULL, 0, 30, NULL, 'draft', 28, NULL, '2026-02-16 13:32:42', '2026-02-16 13:32:42'),
(3, 1, 'CONTRACT-20260217094236-503', 3, 1, 7000.00, 'USD', '2026-02-17', '2026-02-28', NULL, NULL, NULL, NULL, 0, 30, NULL, 'draft', 28, NULL, '2026-02-17 04:12:36', '2026-02-17 04:12:36'),
(4, 1, 'CONTRACT-20260217102358-271', 4, 1, 9500.00, 'USD', '2026-02-17', '2027-02-17', 99.50, 30, NULL, NULL, 1, 30, NULL, 'active', 28, NULL, '2026-02-17 04:53:58', '2026-02-17 04:53:58'),
(5, 1, 'CONTRACT-20260217103319-831', 5, 1, 13500.00, 'USD', '2026-02-17', '2028-02-17', 99.90, 15, 24, NULL, 1, 60, NULL, 'active', 28, NULL, '2026-02-17 05:03:19', '2026-02-17 05:03:19'),
(6, 1, 'CONTRACT-20260217104112-601', 6, 1, 8000.00, 'USD', '2026-02-17', '2027-02-17', 99.50, NULL, NULL, NULL, 0, 30, NULL, 'active', 28, NULL, '2026-02-17 05:11:12', '2026-02-17 05:11:12'),
(7, 1, 'CONTRACT-20260217104232-627', 7, 1, 8000.00, 'USD', '2026-02-17', '2027-02-17', 99.50, NULL, NULL, NULL, 0, 30, NULL, 'active', 28, NULL, '2026-02-17 05:12:32', '2026-02-17 05:12:32'),
(8, 1, 'CONTRACT-20260217104454-297', 8, 1, 8000.00, 'USD', '2026-02-17', '2027-02-17', 99.50, NULL, NULL, NULL, 0, 30, NULL, 'active', 28, NULL, '2026-02-17 05:14:54', '2026-02-17 05:14:54'),
(9, 1, 'CONTRACT-20260217104600-612', 9, 1, 13500.00, 'USD', '2026-02-17', '2028-02-17', 99.90, 15, 24, NULL, 1, 60, NULL, 'active', 28, NULL, '2026-02-17 05:16:00', '2026-02-17 05:16:00'),
(10, 1, 'CONTRACT-20260217110703-835', 10, 1, 17000.00, 'USD', '2026-02-17', '2029-02-17', 99.90, 20, 48, NULL, 1, 90, NULL, 'active', 28, NULL, '2026-02-17 05:37:03', '2026-02-17 05:37:03'),
(11, 1, 'CONTRACT-20260217111227-898', 11, 1, 50000.00, 'USD', '2026-02-17', '2026-02-28', NULL, NULL, NULL, NULL, 0, 30, NULL, 'draft', 28, NULL, '2026-02-17 05:42:27', '2026-02-17 05:42:27'),
(12, 1, 'CONTRACT-20260217111938-376', 11, 1, 9000.00, 'USD', '2026-02-17', '2026-02-28', NULL, NULL, NULL, NULL, 0, 30, NULL, 'draft', 28, NULL, '2026-02-17 05:49:38', '2026-02-17 05:49:38'),
(13, 1, 'CONTRACT-20260217112751-341', 12, 1, 22500.00, 'USD', '2026-02-17', '2028-02-17', NULL, NULL, NULL, NULL, 0, 30, NULL, 'active', 28, NULL, '2026-02-17 05:57:51', '2026-02-17 05:57:51'),
(14, 1, 'CONTRACT-20260217113612-917', 13, 1, 60000.00, 'USD', '2026-02-17', '2026-02-28', NULL, NULL, NULL, NULL, 0, 30, NULL, 'draft', 28, NULL, '2026-02-17 06:06:12', '2026-02-17 06:06:12');

-- --------------------------------------------------------

--
-- Table structure for table `crm_leads`
--

CREATE TABLE `crm_leads` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `lead_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `source_type` enum('website','call','email','referral','event','cold_outreach') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `lead_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `lead_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `industry` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `estimated_monthly_trips` int(11) DEFAULT NULL,
  `estimated_monthly_budget` decimal(12,2) DEFAULT NULL,
  `status` enum('lead_created','lead_qualified','contacted','quoted','converted','lost') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'lead_created',
  `assigned_to` bigint(20) UNSIGNED DEFAULT NULL,
  `converted_to_account_id` bigint(20) UNSIGNED DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tags` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `crm_leads`
--

INSERT INTO `crm_leads` (`id`, `tenant_id`, `lead_number`, `source_type`, `lead_name`, `lead_email`, `lead_phone`, `company_name`, `industry`, `estimated_monthly_trips`, `estimated_monthly_budget`, `status`, `assigned_to`, `converted_to_account_id`, `notes`, `tags`, `created_at`, `updated_at`) VALUES
(1, 1, 'LEAD-20260216183348-313', 'call', 'John Doe', 'fsdfdsf@gmail.com', '08888888888', 'ABCD', NULL, NULL, 100.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-16 13:03:48', '2026-02-16 13:05:46'),
(2, 1, 'LEAD-20260216183438-994', 'referral', 'Bhola Nath Tewari', 'dfgdg@gmail.com', '8999999999', 'XYZ', NULL, NULL, 7000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-16 13:04:38', '2026-02-16 13:05:07'),
(3, 1, 'LEAD-20260217093834-813', 'referral', 'Black Car Rides', 'admin@blackcarrides.com', '9999999999', 'Black Car Rides', NULL, NULL, 20000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 04:08:34', '2026-02-17 04:09:44'),
(4, 1, 'LEAD-20260217102355-610', 'website', 'Test Lead Company 1771323833', 'lead-1771323833@example.com', '+1-555-1234', 'Test Lead Corp', 'Technology', 100, 50000.00, 'quoted', NULL, NULL, 'Test lead for LQC flow', '[]', '2026-02-17 04:53:55', '2026-02-17 04:53:56'),
(5, 1, 'LEAD-20260217103317-112', 'email', 'Test Lead 1771324396', 'lead-1771324396@example.com', '+1-555-5678', 'Test Company', 'Finance', 200, 75000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:03:17', '2026-02-17 05:03:18'),
(6, 1, 'LEAD-20260217104110-369', 'call', 'No-User Lead 1771324869', 'nouser-1771324869@example.com', '+1-555-9999', 'Test Company 2', 'Healthcare', 150, 50000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:11:10', '2026-02-17 05:11:11'),
(7, 1, 'LEAD-20260217104231-860', 'call', 'No-User Lead 1771324950', 'nouser-1771324950@example.com', '+1-555-9999', 'Test Company 2', 'Healthcare', 150, 50000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:12:31', '2026-02-17 05:12:32'),
(8, 1, 'LEAD-20260217104452-856', 'call', 'No-User Lead 1771325091', 'nouser-1771325091@example.com', '+1-555-9999', 'Test Company 2', 'Healthcare', 150, 50000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:14:52', '2026-02-17 05:14:53'),
(9, 1, 'LEAD-20260217104558-709', 'email', 'Test Lead 1771325157', 'lead-1771325157@example.com', '+1-555-5678', 'Test Company', 'Finance', 200, 75000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:15:58', '2026-02-17 05:15:59'),
(10, 1, 'LEAD-20260217110700-124', 'website', 'John Doe Inc', 'newclient-1771326419@example.com', '+1-555-7777', 'New Client Corp 20260217', 'Manufacturing', 300, 100000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:37:00', '2026-02-17 05:37:02'),
(11, 1, 'LEAD-20260217111057-679', 'event', 'Ravi Sharma', 'ravisharma@xyzpro.com', '6666666666', 'XYZ PRO', NULL, NULL, 8000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:40:57', '2026-02-17 05:41:33'),
(12, 1, 'LEAD-20260217112750-435', 'referral', 'Final Test Lead 1771327669', 'finaltest-1771327669@example.com', '+1-555-9111', 'Final Test Corp', 'Retail', 250, 75000.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 05:57:50', '2026-02-17 05:57:51'),
(13, 1, 'LEAD-20260217113458-853', 'event', 'Sanju Sharma', 'sanju@bcci.com', '4444444444', 'BCCI', NULL, NULL, 8999.00, 'quoted', NULL, NULL, NULL, '[]', '2026-02-17 06:04:58', '2026-02-17 06:05:42');

-- --------------------------------------------------------

--
-- Table structure for table `crm_quotes`
--

CREATE TABLE `crm_quotes` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `quote_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `lead_id` bigint(20) UNSIGNED DEFAULT NULL,
  `corporate_account_id` bigint(20) UNSIGNED DEFAULT NULL,
  `base_rate` decimal(12,2) DEFAULT NULL,
  `discount_percentage` decimal(5,2) DEFAULT NULL,
  `discount_amount` decimal(12,2) DEFAULT NULL,
  `total_amount` decimal(12,2) DEFAULT NULL,
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `validity_days` int(11) NOT NULL DEFAULT 30,
  `quote_date` date DEFAULT NULL,
  `valid_until` date DEFAULT NULL,
  `vehicles_included` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `terms` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_terms` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('draft','sent','under_review','accepted','rejected','expired') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `generated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `sent_at` timestamp NULL DEFAULT NULL,
  `accepted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `crm_quotes`
--

INSERT INTO `crm_quotes` (`id`, `tenant_id`, `quote_number`, `lead_id`, `corporate_account_id`, `base_rate`, `discount_percentage`, `discount_amount`, `total_amount`, `currency`, `validity_days`, `quote_date`, `valid_until`, `vehicles_included`, `terms`, `payment_terms`, `status`, `generated_by`, `sent_at`, `accepted_at`, `created_at`, `updated_at`) VALUES
(1, 1, 'QUOTE-20260216183507-927', 2, 1, 2000.00, 0.00, 0.00, 2000.00, 'USD', 30, '2026-02-16', '2026-03-18', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-16 13:05:07', '2026-02-16 13:26:11'),
(2, 1, 'QUOTE-20260216183546-140', 1, 1, 7000.00, 0.00, 0.00, 7000.00, 'USD', 30, '2026-02-16', '2026-03-18', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-16 13:05:46', '2026-02-16 13:32:42'),
(3, 1, 'QUOTE-20260217093944-881', 3, 1, 5000.00, 0.00, 0.00, 5000.00, 'USD', 30, '2026-02-17', '2026-03-19', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-17 04:09:44', '2026-02-17 04:12:36'),
(4, 1, 'QUOTE-20260217102356-735', 4, 1, 10000.00, 5.00, 500.00, 9500.00, 'USD', 30, '2026-02-17', '2026-03-19', '[\"vehicle_1\",\"vehicle_2\"]', 'Net 30', '50% upfront, 50% on delivery', 'accepted', 28, NULL, NULL, '2026-02-17 04:53:56', '2026-02-17 04:53:58'),
(5, 1, 'QUOTE-20260217103318-135', 5, 1, 15000.00, 10.00, 1500.00, 13500.00, 'USD', 45, '2026-02-17', '2026-04-03', '[]', 'Net 30', NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:03:18', '2026-02-17 05:03:19'),
(6, 1, 'QUOTE-20260217104111-409', 6, 1, 8000.00, 0.00, 0.00, 8000.00, 'USD', 30, '2026-02-17', '2026-03-19', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:11:11', '2026-02-17 05:11:12'),
(7, 1, 'QUOTE-20260217104232-262', 7, 1, 8000.00, 0.00, 0.00, 8000.00, 'USD', 30, '2026-02-17', '2026-03-19', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:12:32', '2026-02-17 05:12:32'),
(8, 1, 'QUOTE-20260217104453-425', 8, 1, 8000.00, 0.00, 0.00, 8000.00, 'USD', 30, '2026-02-17', '2026-03-19', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:14:53', '2026-02-17 05:14:54'),
(9, 1, 'QUOTE-20260217104559-248', 9, 1, 15000.00, 10.00, 1500.00, 13500.00, 'USD', 45, '2026-02-17', '2026-04-03', '[]', 'Net 30', NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:15:59', '2026-02-17 05:16:00'),
(10, 1, 'QUOTE-20260217110702-192', 10, 1, 20000.00, 15.00, 3000.00, 17000.00, 'USD', 45, '2026-02-17', '2026-04-03', '[]', 'Net 30', NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:37:02', '2026-02-17 05:37:03'),
(11, 1, 'QUOTE-20260217111133-442', 11, 1, 60000.00, 0.00, 0.00, 60000.00, 'USD', 30, '2026-02-17', '2026-03-19', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:41:33', '2026-02-17 05:42:27'),
(12, 1, 'QUOTE-20260217112751-226', 12, 1, 25000.00, 10.00, 2500.00, 22500.00, 'USD', 60, '2026-02-17', '2026-04-18', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-17 05:57:51', '2026-02-17 05:57:51'),
(13, 1, 'QUOTE-20260217113542-771', 13, 1, 8000.00, 0.00, 0.00, 8000.00, 'USD', 900, '2026-02-17', '2028-08-05', '[]', NULL, NULL, 'accepted', 28, NULL, NULL, '2026-02-17 06:05:42', '2026-02-17 06:06:12');

-- --------------------------------------------------------

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `phone` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `tenant_id` bigint(20) UNSIGNED DEFAULT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `customers`
--

INSERT INTO `customers` (`id`, `name`, `phone`, `email`, `tenant_id`, `user_id`, `created_at`, `updated_at`) VALUES
(1, 'Test Passenger', '+91 98765 43290', 'test.passenger.1234@limozx.local', 1, 37, '2026-02-15 13:03:16', '2026-02-15 13:03:16'),
(2, 'Amit Menon', '+44 9713 9733', 'customer_amit_menon_1771182106567@limozx.local', 1, 38, '2026-02-15 13:32:01', '2026-02-15 13:32:01'),
(3, 'Isha Gupta', '+91 1953 3092', 'customer_isha_gupta_1771182129919@limozx.local', 1, 39, '2026-02-15 13:32:19', '2026-02-15 13:32:19');

-- --------------------------------------------------------

--
-- Table structure for table `customer_surveys`
--

CREATE TABLE `customer_surveys` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `corporate_account_id` bigint(20) UNSIGNED NOT NULL,
  `survey_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('draft','active','closed') NOT NULL DEFAULT 'draft',
  `total_responses` int(11) NOT NULL DEFAULT 0,
  `satisfaction_score` decimal(3,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `daily_analytics`
--

CREATE TABLE `daily_analytics` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `analytics_date` date NOT NULL,
  `total_bookings` int(11) NOT NULL DEFAULT 0,
  `total_revenue` decimal(12,2) NOT NULL DEFAULT 0.00,
  `total_drivers_active` int(11) NOT NULL DEFAULT 0,
  `total_passengers_active` int(11) NOT NULL DEFAULT 0,
  `average_ride_rating` decimal(3,2) DEFAULT NULL,
  `average_ride_time_minutes` int(11) DEFAULT NULL,
  `cancellation_rate` decimal(5,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `department_budgets`
--

CREATE TABLE `department_budgets` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `corporate_account_id` bigint(20) UNSIGNED NOT NULL,
  `department_name` varchar(100) NOT NULL,
  `total_budget` decimal(12,2) NOT NULL,
  `spent_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `month` int(11) DEFAULT NULL,
  `year` int(11) DEFAULT NULL,
  `budget_reset_day` int(11) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `dispatcher_shifts`
--

CREATE TABLE `dispatcher_shifts` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `dispatcher_id` bigint(20) UNSIGNED NOT NULL,
  `shift_date` date NOT NULL,
  `start_time` time DEFAULT NULL,
  `end_time` time DEFAULT NULL,
  `status` enum('scheduled','in_progress','completed','canceled') NOT NULL DEFAULT 'scheduled',
  `total_trips_assigned` int(11) NOT NULL DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `disputes`
--

CREATE TABLE `disputes` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `dispute_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `booking_id` bigint(20) UNSIGNED DEFAULT NULL,
  `complaint_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reported_by_id` bigint(20) UNSIGNED NOT NULL,
  `reported_against_id` bigint(20) UNSIGNED NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `evidence_urls` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `status` enum('open','under_review','resolved','closed','escalated') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `resolution` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `resolution_date` timestamp NULL DEFAULT NULL,
  `compensation_amount` decimal(12,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `documents`
--

CREATE TABLE `documents` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `document_type` varchar(100) DEFAULT NULL,
  `owner_type` varchar(50) DEFAULT NULL,
  `owner_id` bigint(20) UNSIGNED DEFAULT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(500) DEFAULT NULL,
  `file_size` int(11) DEFAULT NULL,
  `mime_type` varchar(100) DEFAULT NULL,
  `uploaded_by` bigint(20) UNSIGNED DEFAULT NULL,
  `expiry_date` date DEFAULT NULL,
  `is_verified` tinyint(1) NOT NULL DEFAULT 0,
  `verified_by` bigint(20) UNSIGNED DEFAULT NULL,
  `verified_date` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `feature_toggles`
--

CREATE TABLE `feature_toggles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED DEFAULT NULL,
  `feature_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `is_enabled` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `health_scores`
--

CREATE TABLE `health_scores` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `customer_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `overall_score` int(11) NOT NULL DEFAULT 0,
  `metrics` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `status` enum('excellent','good','at_risk','critical') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'good',
  `last_ride` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_rides` int(11) NOT NULL DEFAULT 0,
  `total_spending` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `trends` enum('improving','stable','declining') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'stable',
  `recommendations` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `interactions`
--

CREATE TABLE `interactions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED DEFAULT NULL,
  `customer_id` bigint(20) UNSIGNED NOT NULL,
  `customer_name` varchar(255) NOT NULL,
  `type` enum('call','message','email','in_app','support_ticket') NOT NULL DEFAULT 'call',
  `subject` varchar(255) NOT NULL,
  `status` enum('pending','completed','follow_up_needed') NOT NULL DEFAULT 'pending',
  `priority` enum('low','medium','high') NOT NULL DEFAULT 'medium',
  `notes` text DEFAULT NULL,
  `resolution` text DEFAULT NULL,
  `interaction_date` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `interactions`
--

INSERT INTO `interactions` (`id`, `tenant_id`, `customer_id`, `customer_name`, `type`, `subject`, `status`, `priority`, `notes`, `resolution`, `interaction_date`, `created_by`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 'Amit Menon', 'message', 'sdfdsf', 'pending', 'high', 'f dsf sd fsd fsdf', NULL, '2026-02-16 04:12:32', 28, '2026-02-16 04:12:32', '2026-02-16 04:12:32'),
(2, 1, 3, 'Isha Gupta', 'support_ticket', 'Test Pro', 'pending', 'medium', 'Dest Pro', NULL, '2026-02-16 09:53:29', 28, '2026-02-16 09:53:29', '2026-02-16 09:53:29');

-- --------------------------------------------------------

--
-- Table structure for table `invoices`
--

CREATE TABLE `invoices` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `invoice_number` varchar(50) NOT NULL,
  `billing_period_start` date DEFAULT NULL,
  `billing_period_end` date DEFAULT NULL,
  `total_amount` decimal(12,2) NOT NULL,
  `tax_amount` decimal(12,2) DEFAULT NULL,
  `currency` varchar(3) NOT NULL DEFAULT 'USD',
  `status` enum('draft','sent','paid','overdue','canceled') NOT NULL DEFAULT 'draft',
  `due_date` date DEFAULT NULL,
  `paid_date` date DEFAULT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `marketing_campaigns`
--

CREATE TABLE `marketing_campaigns` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `corporate_account_id` bigint(20) UNSIGNED NOT NULL,
  `campaign_name` varchar(255) NOT NULL,
  `campaign_type` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `budget` decimal(12,2) DEFAULT NULL,
  `target_audience` varchar(255) DEFAULT NULL,
  `status` enum('draft','active','completed','paused','canceled') NOT NULL DEFAULT 'draft',
  `roi_percentage` decimal(5,2) DEFAULT NULL,
  `impressions` int(11) NOT NULL DEFAULT 0,
  `clicks` int(11) NOT NULL DEFAULT 0,
  `conversions` int(11) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(255) NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2019_12_14_000001_create_personal_access_tokens_table', 1),
(2, '2024_01_01_000000_create_users_table', 1),
(3, '2024_01_21_000001_add_jwt_columns_to_users_table', 1),
(4, '2026_01_19_000002_create_user_profiles_table', 1),
(5, '2026_01_19_000003_create_api_keys_table', 1),
(6, '2026_01_19_000004_create_tenants_table', 1),
(7, '2026_01_19_000005_create_tenant_settings_table', 1),
(8, '2026_01_19_000006_create_roles_table', 1),
(9, '2026_01_19_000007_create_permissions_table', 1),
(10, '2026_01_19_000008_create_user_roles_table', 1),
(11, '2026_01_19_000009_create_operators_table', 1),
(12, '2026_01_19_000010_create_vehicles_table', 1),
(13, '2026_01_19_000011_create_drivers_table', 1),
(14, '2026_01_19_000012_create_passengers_table', 1),
(15, '2026_01_19_000013_create_saved_locations_table', 1),
(16, '2026_01_19_000014_create_bookings_table', 1),
(17, '2026_01_19_000015_create_trip_tracking_table', 1),
(18, '2026_01_19_000016_create_trip_ratings_table', 1),
(19, '2026_01_19_000017_create_corporate_accounts_table', 1),
(20, '2026_01_19_000018_create_corporate_travelers_table', 1),
(21, '2026_01_19_000019_create_travel_policies_table', 1),
(22, '2026_01_19_000020_create_booking_approvals_table', 1),
(23, '2026_01_19_000021_create_department_budgets_table', 1),
(24, '2026_01_19_000022_create_affiliates_table', 1),
(25, '2026_01_19_000023_create_affiliate_leads_table', 1),
(26, '2026_01_19_000024_create_payments_table', 1),
(27, '2026_01_19_000025_create_payouts_table', 1),
(28, '2026_01_19_000026_create_commissions_table', 1),
(29, '2026_01_19_000027_create_rfq_requests_table', 1),
(30, '2026_01_19_000028_create_bids_table', 1),
(31, '2026_01_19_000029_create_bid_attachments_table', 1),
(32, '2026_01_19_000030_create_crm_leads_table', 1),
(33, '2026_01_19_000031_create_crm_quotes_table', 1),
(34, '2026_01_19_000032_create_crm_contracts_table', 1),
(35, '2026_01_19_000033_create_corporate_clients_table', 1),
(36, '2026_01_19_000034_create_documents_table', 1),
(37, '2026_01_19_000035_create_audit_logs_table', 1),
(38, '2026_01_19_000036_create_partners_table', 1),
(39, '2026_01_19_000037_create_disputes_table', 1),
(40, '2026_01_19_000038_create_marketing_campaigns_table', 1),
(41, '2026_01_19_000039_create_customer_surveys_table', 1),
(42, '2026_01_19_000040_create_survey_responses_table', 1),
(43, '2026_01_19_000041_create_sla_metrics_table', 1),
(44, '2026_01_19_000042_create_sla_violations_table', 1),
(45, '2026_01_19_000043_create_partner_staff_table', 1),
(46, '2026_01_19_000044_create_daily_analytics_table', 1),
(47, '2026_01_19_000045_create_performance_metrics_table', 1),
(48, '2026_01_19_000046_create_compliance_checks_table', 1),
(49, '2026_01_19_000047_create_system_metrics_table', 1),
(50, '2026_01_19_000048_create_server_status_table', 1),
(51, '2026_01_19_000049_create_subscription_plans_table', 1),
(52, '2026_01_19_000050_create_feature_toggles_table', 1),
(53, '2026_01_19_000051_create_invoices_table', 1),
(54, '2026_01_19_000052_create_dispatcher_shifts_table', 1),
(55, '2026_01_29_000001_add_tenant_id_to_users_table', 1),
(56, '2026_01_29_000053_add_tenant_id_to_users_table', 1),
(57, '2026_01_29_000054_add_missing_columns_to_users_table', 1),
(58, '2026_01_30_000000_make_operator_id_nullable_in_vehicles', 1),
(59, '2026_01_30_add_tenant_id_to_users', 1),
(60, '2026_02_01_120000_add_last_login_at_to_users_table', 1),
(61, '2026_02_01_130000_create_customers_table', 1),
(62, '2026_02_03_000000_update_crm_leads_status_enum', 1),
(63, '2026_02_15_add_admin_user_id_to_tenants', 1),
(64, '2026_02_16_add_user_id_to_customers_table', 2),
(65, '2026_02_16_rename_passenger_fk_on_bookings_table', 3),
(66, '2026_02_16_create_interactions_table', 4),
(67, '2026_02_16_create_segments_table', 5),
(68, '2026_02_16_create_segment_criteria_table', 6),
(69, '2026_02_16_create_activities_table', 7),
(70, '2026_02_16_create_communications_table', 8),
(71, '2026_02_16_create_health_scores_table', 8),
(72, '2026_02_17_000001_add_corporate_account_id_to_users', 9);

-- --------------------------------------------------------

--
-- Table structure for table `operators`
--

CREATE TABLE `operators` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `business_name` varchar(255) NOT NULL,
  `business_registration_number` varchar(100) DEFAULT NULL,
  `tax_id` varchar(100) DEFAULT NULL,
  `status` enum('active','inactive','suspended','pending_approval') NOT NULL DEFAULT 'pending_approval',
  `commission_rate` decimal(5,2) DEFAULT NULL,
  `bank_account_holder` varchar(255) DEFAULT NULL,
  `bank_account_number` varchar(50) DEFAULT NULL,
  `bank_routing_number` varchar(50) DEFAULT NULL,
  `bank_name` varchar(255) DEFAULT NULL,
  `total_drivers` int(11) NOT NULL DEFAULT 0,
  `total_vehicles` int(11) NOT NULL DEFAULT 0,
  `total_trips` int(11) NOT NULL DEFAULT 0,
  `average_rating` decimal(3,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `partners`
--

CREATE TABLE `partners` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `partner_type` enum('hotel','restaurant','venue','agency','other') NOT NULL,
  `business_name` varchar(255) NOT NULL,
  `address` varchar(500) DEFAULT NULL,
  `city` varchar(100) DEFAULT NULL,
  `country` varchar(100) DEFAULT NULL,
  `contact_person` varchar(255) DEFAULT NULL,
  `contact_phone` varchar(20) DEFAULT NULL,
  `contact_email` varchar(255) DEFAULT NULL,
  `status` enum('active','inactive','pending','suspended') NOT NULL DEFAULT 'pending',
  `commission_rate` decimal(5,2) DEFAULT NULL,
  `total_bookings` int(11) NOT NULL DEFAULT 0,
  `total_revenue` decimal(12,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `partner_staff`
--

CREATE TABLE `partner_staff` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `partner_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `role` varchar(100) DEFAULT NULL,
  `shift_start` time DEFAULT NULL,
  `shift_end` time DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `passengers`
--

CREATE TABLE `passengers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `status` enum('active','inactive','suspended') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `phone_verified` tinyint(1) NOT NULL DEFAULT 0,
  `payment_method_on_file` tinyint(1) NOT NULL DEFAULT 0,
  `preferred_payment_method` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_trips` int(11) NOT NULL DEFAULT 0,
  `total_spent` decimal(12,2) NOT NULL DEFAULT 0.00,
  `average_rating` decimal(3,2) DEFAULT NULL,
  `emergency_contact_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `emergency_contact_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `saved_addresses` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `preferences` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `booking_id` bigint(20) UNSIGNED DEFAULT NULL,
  `payer_type` enum('passenger','corporate_account','affiliate') DEFAULT NULL,
  `payer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `amount` decimal(12,2) NOT NULL,
  `currency` varchar(3) NOT NULL DEFAULT 'USD',
  `payment_method` varchar(50) DEFAULT NULL,
  `payment_gateway` varchar(50) DEFAULT NULL,
  `transaction_id` varchar(255) DEFAULT NULL,
  `status` enum('pending','processing','completed','failed','refunded') NOT NULL DEFAULT 'pending',
  `refund_reason` varchar(500) DEFAULT NULL,
  `refund_amount` decimal(12,2) DEFAULT NULL,
  `refund_date` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `payouts`
--

CREATE TABLE `payouts` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `payout_number` varchar(50) NOT NULL,
  `recipient_type` enum('driver','operator','affiliate') NOT NULL,
  `recipient_id` bigint(20) UNSIGNED NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `currency` varchar(3) NOT NULL DEFAULT 'USD',
  `period_start` date DEFAULT NULL,
  `period_end` date DEFAULT NULL,
  `status` enum('pending','processing','completed','failed','canceled') NOT NULL DEFAULT 'pending',
  `payment_method` varchar(50) DEFAULT NULL,
  `bank_account_id` bigint(20) UNSIGNED DEFAULT NULL,
  `processing_date` timestamp NULL DEFAULT NULL,
  `completed_date` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `performance_metrics`
--

CREATE TABLE `performance_metrics` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `metric_type` varchar(100) DEFAULT NULL,
  `metric_name` varchar(255) NOT NULL,
  `metric_value` decimal(12,4) DEFAULT NULL,
  `metric_unit` varchar(50) DEFAULT NULL,
  `period_type` enum('daily','weekly','monthly','quarterly','yearly') DEFAULT NULL,
  `period_start_date` date DEFAULT NULL,
  `period_end_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `permission_name` varchar(255) NOT NULL,
  `resource` varchar(100) DEFAULT NULL,
  `action` varchar(50) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `rfq_requests`
--

CREATE TABLE `rfq_requests` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `rfq_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_by_type` enum('corporate_account','operator') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_by_id` bigint(20) UNSIGNED NOT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `service_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_trips` int(11) DEFAULT NULL,
  `budget_amount` decimal(12,2) DEFAULT NULL,
  `budget_currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `preferred_operators` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `pickup_addresses` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `dropoff_addresses` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `scheduled_dates` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `vehicle_requirements` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `status` enum('draft','published','bids_received','closed','awarded','canceled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `published_at` timestamp NULL DEFAULT NULL,
  `bid_deadline` timestamp NULL DEFAULT NULL,
  `award_date` date DEFAULT NULL,
  `awarded_to` bigint(20) UNSIGNED DEFAULT NULL,
  `visibility` enum('private','public','selected') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'public',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED DEFAULT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `permission_count` int(11) NOT NULL DEFAULT 0,
  `user_count` int(11) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `saved_locations`
--

CREATE TABLE `saved_locations` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `passenger_id` bigint(20) UNSIGNED NOT NULL,
  `label` varchar(50) DEFAULT NULL,
  `address` varchar(500) NOT NULL,
  `city` varchar(100) DEFAULT NULL,
  `latitude` decimal(10,8) DEFAULT NULL,
  `longitude` decimal(11,8) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `segments`
--

CREATE TABLE `segments` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `color` varchar(255) NOT NULL DEFAULT '#007bff',
  `criteria` text DEFAULT NULL,
  `customer_count` int(11) NOT NULL DEFAULT 0,
  `avg_ride_frequency` varchar(255) DEFAULT '0 rides/month',
  `avg_spending` varchar(255) DEFAULT '₹0/month',
  `retention` varchar(255) DEFAULT '0%',
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `segments`
--

INSERT INTO `segments` (`id`, `tenant_id`, `name`, `description`, `color`, `criteria`, `customer_count`, `avg_ride_frequency`, `avg_spending`, `retention`, `created_by`, `created_at`, `updated_at`) VALUES
(1, 1, 'VIP Customer', 'dfgdfg', '#007bff', '200', 1, '1 rides/month', '₹32,672.00/month', '0%', 28, '2026-02-16 05:08:35', '2026-02-16 08:41:59');

-- --------------------------------------------------------

--
-- Table structure for table `segment_criteria`
--

CREATE TABLE `segment_criteria` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `segment_id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `rules` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `min_avg_fare` decimal(10,2) DEFAULT NULL,
  `max_avg_fare` decimal(10,2) DEFAULT NULL,
  `min_total_trips` int(11) NOT NULL DEFAULT 0,
  `max_total_trips` int(11) DEFAULT NULL,
  `min_total_spent` decimal(12,2) DEFAULT NULL,
  `max_total_spent` decimal(12,2) DEFAULT NULL,
  `min_avg_rating` decimal(3,2) DEFAULT NULL,
  `payment_method_required` tinyint(1) NOT NULL DEFAULT 0,
  `phone_verified_required` tinyint(1) NOT NULL DEFAULT 0,
  `preferred_trip_types` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `inactive_days_threshold` int(11) DEFAULT NULL,
  `active_months_lookback` int(11) NOT NULL DEFAULT 3,
  `behavioral_rules` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `segment_criteria`
--

INSERT INTO `segment_criteria` (`id`, `segment_id`, `tenant_id`, `rules`, `min_avg_fare`, `max_avg_fare`, `min_total_trips`, `max_total_trips`, `min_total_spent`, `max_total_spent`, `min_avg_rating`, `payment_method_required`, `phone_verified_required`, `preferred_trip_types`, `inactive_days_threshold`, `active_months_lookback`, `behavioral_rules`, `created_at`, `updated_at`) VALUES
(1, 1, 1, NULL, NULL, NULL, 2, NULL, 2000.00, NULL, NULL, 0, 0, '[]', NULL, 3, NULL, '2026-02-16 05:33:58', '2026-02-18 10:37:32');

-- --------------------------------------------------------

--
-- Table structure for table `server_status`
--

CREATE TABLE `server_status` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `server_name` varchar(255) NOT NULL,
  `uptime_percentage` decimal(5,2) DEFAULT NULL,
  `cpu_usage` decimal(5,2) DEFAULT NULL,
  `memory_usage` decimal(5,2) DEFAULT NULL,
  `disk_usage` decimal(5,2) DEFAULT NULL,
  `status` enum('online','warning','offline') NOT NULL DEFAULT 'online',
  `last_check` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `sla_metrics`
--

CREATE TABLE `sla_metrics` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `booking_id` bigint(20) UNSIGNED NOT NULL,
  `response_time_minutes` int(11) DEFAULT NULL,
  `assignment_time_minutes` int(11) DEFAULT NULL,
  `arrival_time_minutes` int(11) DEFAULT NULL,
  `completion_time_minutes` int(11) DEFAULT NULL,
  `sla_target_minutes` int(11) DEFAULT NULL,
  `status` enum('met','at_risk','breached') NOT NULL DEFAULT 'met',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `sla_violations`
--

CREATE TABLE `sla_violations` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `booking_id` bigint(20) UNSIGNED NOT NULL,
  `sla_metric_id` bigint(20) UNSIGNED DEFAULT NULL,
  `violation_type` varchar(100) DEFAULT NULL,
  `impact_description` text DEFAULT NULL,
  `penalty_amount` decimal(12,2) DEFAULT NULL,
  `status` enum('pending','reviewed','approved','disputed','resolved') NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `subscription_plans`
--

CREATE TABLE `subscription_plans` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `plan_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `billing_cycle` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `max_users` int(11) DEFAULT NULL,
  `max_bookings_per_month` int(11) DEFAULT NULL,
  `features` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `subscription_plans`
--

INSERT INTO `subscription_plans` (`id`, `plan_name`, `description`, `price`, `billing_cycle`, `max_users`, `max_bookings_per_month`, `features`, `created_at`, `updated_at`) VALUES
(1, 'Starter', 'Perfect for small businesses getting started', 99.99, 'monthly', 5, 100, '\"[\\\"Basic Dashboard\\\",\\\"Up to 5 Users\\\",\\\"Email Support\\\",\\\"Standard Reports\\\",\\\"API Access (Basic)\\\"]\"', '2026-02-15 12:01:10', '2026-02-15 12:01:10'),
(2, 'Professional', 'Ideal for growing businesses with advanced needs', 299.99, 'monthly', 25, 1000, '\"[\\\"Advanced Dashboard\\\",\\\"Up to 25 Users\\\",\\\"Priority Email & Phone Support\\\",\\\"Advanced Analytics\\\",\\\"Full API Access\\\",\\\"Custom Integrations\\\",\\\"Team Collaboration\\\"]\"', '2026-02-15 12:01:10', '2026-02-15 12:01:10'),
(3, 'Enterprise', 'Comprehensive solution for large enterprises', 999.99, 'monthly', 500, 100000, '\"[\\\"Enterprise Dashboard\\\",\\\"Unlimited Users\\\",\\\"24\\\\\\/7 Dedicated Support\\\",\\\"Custom Analytics & Reports\\\",\\\"Unlimited API Calls\\\",\\\"White-label Solutions\\\",\\\"Advanced Security Features\\\",\\\"Custom Workflows\\\",\\\"Dedicated Account Manager\\\"]\"', '2026-02-15 12:01:10', '2026-02-15 12:01:10'),
(4, 'Premium', 'Enhanced professional plan with premium features', 499.99, 'monthly', 100, 10000, '\"[\\\"Premium Dashboard\\\",\\\"Up to 100 Users\\\",\\\"Priority Support 24\\\\\\/7\\\",\\\"Real-time Analytics\\\",\\\"Advanced API Access\\\",\\\"Custom Branding\\\",\\\"Advanced Reporting\\\",\\\"SSO Integration\\\"]\"', '2026-02-15 12:01:10', '2026-02-15 12:01:10');

-- --------------------------------------------------------

--
-- Table structure for table `survey_responses`
--

CREATE TABLE `survey_responses` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `survey_id` bigint(20) UNSIGNED NOT NULL,
  `respondent_id` bigint(20) UNSIGNED DEFAULT NULL,
  `rating` int(11) DEFAULT NULL,
  `feedback` text DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `system_metrics`
--

CREATE TABLE `system_metrics` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `metric_name` varchar(100) NOT NULL,
  `metric_value` decimal(10,2) DEFAULT NULL,
  `metric_unit` varchar(50) DEFAULT NULL,
  `status` enum('healthy','warning','critical') NOT NULL DEFAULT 'healthy',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `tenants`
--

CREATE TABLE `tenants` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `admin_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `slug` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `logo_url` varchar(500) DEFAULT NULL,
  `website_url` varchar(255) DEFAULT NULL,
  `support_email` varchar(255) DEFAULT NULL,
  `support_phone` varchar(20) DEFAULT NULL,
  `status` enum('active','inactive','suspended','trial','premium') NOT NULL DEFAULT 'trial',
  `subscription_plan` varchar(100) DEFAULT NULL,
  `subscription_status` enum('active','inactive','expired','canceled') NOT NULL DEFAULT 'active',
  `subscription_end_date` date DEFAULT NULL,
  `is_white_label` tinyint(1) NOT NULL DEFAULT 0,
  `theme_color` varchar(7) DEFAULT NULL,
  `custom_domain` varchar(255) DEFAULT NULL,
  `api_limit_per_hour` int(11) NOT NULL DEFAULT 10000,
  `max_users` int(11) NOT NULL DEFAULT 100,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `tenants`
--

INSERT INTO `tenants` (`id`, `admin_user_id`, `name`, `slug`, `description`, `logo_url`, `website_url`, `support_email`, `support_phone`, `status`, `subscription_plan`, `subscription_status`, `subscription_end_date`, `is_white_label`, `theme_color`, `custom_domain`, `api_limit_per_hour`, `max_users`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 28, 'TechCorp 379', 'techcorp-379', 'A leading provider of enterprise solutions and digital transformation services', NULL, 'https://techcorp379.com', 'support379@enterprise.co', '+1-415-450-2913', 'active', '4', 'active', '2027-02-15', 0, '#007bff', NULL, 37811, 4198, '2026-02-15 12:09:57', '2026-02-15 12:09:57', NULL),
(2, 29, 'VelocityTech 351', 'velocitytech-351', 'Innovative technology company focused on cloud computing and automation', NULL, 'https://velocitytech351.com', 'support351@tech.com', '+61-2-479-6634', 'active', '3', 'active', '2027-02-15', 0, '#dc3545', NULL, 32740, 1611, '2026-02-15 12:13:29', '2026-02-15 12:13:29', NULL),
(3, 30, 'QuantumEdge 521', 'quantumedge-521', 'Enterprise software provider with cutting-edge technologies', NULL, 'https://quantumedge521.com', 'support521@solutions.io', '+1-800-636-6747', 'active', '3', 'active', '2027-02-15', 0, '#dc3545', NULL, 4344, 4513, '2026-02-15 12:13:56', '2026-02-15 12:13:56', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `travel_policies`
--

CREATE TABLE `travel_policies` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `corporate_account_id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `max_ride_cost` decimal(10,2) DEFAULT NULL,
  `allowed_ride_types` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `blackout_dates` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `pre_approval_required` tinyint(1) NOT NULL DEFAULT 0,
  `approval_required_above_amount` decimal(10,2) DEFAULT NULL,
  `restricted_areas` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `trip_ratings`
--

CREATE TABLE `trip_ratings` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `booking_id` bigint(20) UNSIGNED NOT NULL,
  `passenger_rating` int(11) DEFAULT NULL,
  `driver_rating` int(11) DEFAULT NULL,
  `passenger_feedback` text DEFAULT NULL,
  `driver_feedback` text DEFAULT NULL,
  `passenger_rated_at` timestamp NULL DEFAULT NULL,
  `driver_rated_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `trip_tracking`
--

CREATE TABLE `trip_tracking` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `booking_id` bigint(20) UNSIGNED NOT NULL,
  `latitude` decimal(10,8) DEFAULT NULL,
  `longitude` decimal(11,8) DEFAULT NULL,
  `speed` decimal(5,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `user_profiles`
--

CREATE TABLE `user_profiles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `bio` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `state_province` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `postal_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_of_birth` date DEFAULT NULL,
  `gender` enum('male','female','other','prefer_not_to_say') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `profile_completed` tinyint(1) NOT NULL DEFAULT 0,
  `preferences` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `user_roles`
--

CREATE TABLE `user_roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED DEFAULT NULL,
  `assigned_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `assigned_by` bigint(20) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `vehicles`
--

CREATE TABLE `vehicles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `tenant_id` bigint(20) UNSIGNED NOT NULL,
  `operator_id` bigint(20) UNSIGNED DEFAULT NULL,
  `driver_id` bigint(20) UNSIGNED DEFAULT NULL,
  `registration_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `vehicle_type` enum('sedan','suv','van','truck','hatchback','luxury','electric') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `make` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `year` int(11) DEFAULT NULL,
  `color` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vin` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `license_plate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('active','inactive','maintenance','out_of_service') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `capacity_passengers` int(11) DEFAULT NULL,
  `capacity_luggage` int(11) DEFAULT NULL,
  `features` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `insurance_provider` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `insurance_policy_number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `insurance_expiry` date DEFAULT NULL,
  `registration_expiry` date DEFAULT NULL,
  `inspection_expiry` date DEFAULT NULL,
  `total_trips` int(11) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `vehicles`
--

INSERT INTO `vehicles` (`id`, `tenant_id`, `operator_id`, `driver_id`, `registration_number`, `vehicle_type`, `make`, `model`, `year`, `color`, `vin`, `license_plate`, `status`, `capacity_passengers`, `capacity_luggage`, `features`, `insurance_provider`, `insurance_policy_number`, `insurance_expiry`, `registration_expiry`, `inspection_expiry`, `total_trips`, `created_at`, `updated_at`) VALUES
(1, 1, NULL, 3, 'MH50LM6099', 'sedan', 'Toyota', 'Fortuner', 2023, 'White', '026099VPPTUPV161M', 'KA-85-MI-8697', 'active', 5, 500, NULL, 'HDFC ERGO', 'POL026100', '2027-02-15', '2027-02-15', '2027-02-15', 0, '2026-02-15 12:42:11', '2026-02-15 12:42:11'),
(2, 1, NULL, 2, 'DL53ZW9594', 'sedan', 'Toyota', 'Fortuner', 2023, 'White', '149594O205RP7Z41C', 'KA-40-KS-8667', 'active', 5, 500, NULL, 'HDFC ERGO', 'POL149594', '2027-02-15', '2027-02-15', '2027-02-15', 0, '2026-02-15 12:42:49', '2026-02-15 12:42:49'),
(3, 1, NULL, 1, 'GJ54HX8397', 'sedan', 'Toyota', 'Fortuner', 2023, 'White', '1483970LOY2OVKSRB', 'KA-54-ZZ-5822', 'active', 5, 500, NULL, 'HDFC ERGO', 'POL148397', '2027-02-18', '2027-02-18', '2027-02-18', 0, '2026-02-18 10:26:22', '2026-02-18 10:26:22');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `activities`
--
ALTER TABLE `activities`
  ADD PRIMARY KEY (`id`),
  ADD KEY `activities_created_by_foreign` (`created_by`),
  ADD KEY `activities_tenant_id_index` (`tenant_id`),
  ADD KEY `activities_customer_id_index` (`customer_id`),
  ADD KEY `activities_type_index` (`type`),
  ADD KEY `activities_status_index` (`status`),
  ADD KEY `activities_priority_index` (`priority`),
  ADD KEY `activities_created_at_index` (`created_at`);

--
-- Indexes for table `affiliate_leads`
--
ALTER TABLE `affiliate_leads`
  ADD PRIMARY KEY (`id`),
  ADD KEY `affiliate_leads_converted_booking_id_foreign` (`converted_booking_id`),
  ADD KEY `affiliate_leads_affiliate_id_index` (`affiliate_id`),
  ADD KEY `affiliate_leads_status_index` (`status`);

--
-- Indexes for table `audit_logs`
--
ALTER TABLE `audit_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `audit_logs_tenant_id_index` (`tenant_id`),
  ADD KEY `audit_logs_user_id_index` (`user_id`),
  ADD KEY `audit_logs_created_at_index` (`created_at`),
  ADD KEY `audit_logs_entity_type_index` (`entity_type`);

--
-- Indexes for table `bids`
--
ALTER TABLE `bids`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `bids_bid_number_unique` (`bid_number`),
  ADD KEY `bids_reviewed_by_foreign` (`reviewed_by`),
  ADD KEY `bids_tenant_id_index` (`tenant_id`),
  ADD KEY `bids_rfq_id_index` (`rfq_id`),
  ADD KEY `bids_status_index` (`status`);

--
-- Indexes for table `bid_attachments`
--
ALTER TABLE `bid_attachments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `bid_attachments_bid_id_index` (`bid_id`);

--
-- Indexes for table `bookings`
--
ALTER TABLE `bookings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `bookings_booking_number_unique` (`booking_number`),
  ADD KEY `bookings_vehicle_id_foreign` (`vehicle_id`),
  ADD KEY `bookings_operator_id_foreign` (`operator_id`),
  ADD KEY `bookings_tenant_id_index` (`tenant_id`),
  ADD KEY `bookings_booking_number_index` (`booking_number`),
  ADD KEY `bookings_passenger_id_index` (`passenger_id`),
  ADD KEY `bookings_driver_id_index` (`driver_id`),
  ADD KEY `bookings_status_index` (`status`),
  ADD KEY `bookings_created_at_index` (`created_at`);

--
-- Indexes for table `booking_approvals`
--
ALTER TABLE `booking_approvals`
  ADD PRIMARY KEY (`id`),
  ADD KEY `booking_approvals_corporate_traveler_id_foreign` (`corporate_traveler_id`),
  ADD KEY `booking_approvals_approver_id_foreign` (`approver_id`),
  ADD KEY `booking_approvals_booking_id_index` (`booking_id`),
  ADD KEY `booking_approvals_status_index` (`status`);

--
-- Indexes for table `commissions`
--
ALTER TABLE `commissions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `commissions_payout_id_foreign` (`payout_id`),
  ADD KEY `commissions_tenant_id_index` (`tenant_id`),
  ADD KEY `commissions_booking_id_index` (`booking_id`),
  ADD KEY `commissions_status_index` (`status`);

--
-- Indexes for table `communication_logs`
--
ALTER TABLE `communication_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `communication_logs_created_by_foreign` (`created_by`),
  ADD KEY `communication_logs_tenant_id_index` (`tenant_id`),
  ADD KEY `communication_logs_customer_id_index` (`customer_id`),
  ADD KEY `communication_logs_channel_index` (`channel`),
  ADD KEY `communication_logs_direction_index` (`direction`),
  ADD KEY `communication_logs_sentiment_index` (`sentiment`),
  ADD KEY `communication_logs_timestamp_index` (`timestamp`),
  ADD KEY `communication_logs_created_at_index` (`created_at`);

--
-- Indexes for table `compliance_checks`
--
ALTER TABLE `compliance_checks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `compliance_checks_tenant_id_index` (`tenant_id`),
  ADD KEY `compliance_checks_status_index` (`status`);

--
-- Indexes for table `corporate_accounts`
--
ALTER TABLE `corporate_accounts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `corporate_accounts_user_id_foreign` (`user_id`),
  ADD KEY `corporate_accounts_account_manager_id_foreign` (`account_manager_id`),
  ADD KEY `corporate_accounts_tenant_id_index` (`tenant_id`),
  ADD KEY `corporate_accounts_status_index` (`status`);

--
-- Indexes for table `corporate_clients`
--
ALTER TABLE `corporate_clients`
  ADD PRIMARY KEY (`id`),
  ADD KEY `corporate_clients_corporate_account_id_index` (`corporate_account_id`),
  ADD KEY `corporate_clients_loyalty_tier_index` (`loyalty_tier`);

--
-- Indexes for table `corporate_travelers`
--
ALTER TABLE `corporate_travelers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `corporate_travelers_user_id_foreign` (`user_id`),
  ADD KEY `corporate_travelers_manager_id_foreign` (`manager_id`),
  ADD KEY `corporate_travelers_corporate_account_id_index` (`corporate_account_id`),
  ADD KEY `corporate_travelers_status_index` (`status`);

--
-- Indexes for table `crm_contracts`
--
ALTER TABLE `crm_contracts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `crm_contracts_contract_number_unique` (`contract_number`),
  ADD KEY `crm_contracts_quote_id_foreign` (`quote_id`),
  ADD KEY `crm_contracts_corporate_account_id_foreign` (`corporate_account_id`),
  ADD KEY `crm_contracts_signed_by_foreign` (`signed_by`),
  ADD KEY `crm_contracts_tenant_id_index` (`tenant_id`),
  ADD KEY `crm_contracts_status_index` (`status`);

--
-- Indexes for table `crm_leads`
--
ALTER TABLE `crm_leads`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `crm_leads_lead_number_unique` (`lead_number`),
  ADD KEY `crm_leads_converted_to_account_id_foreign` (`converted_to_account_id`),
  ADD KEY `crm_leads_tenant_id_index` (`tenant_id`),
  ADD KEY `crm_leads_status_index` (`status`),
  ADD KEY `crm_leads_assigned_to_index` (`assigned_to`);

--
-- Indexes for table `crm_quotes`
--
ALTER TABLE `crm_quotes`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `crm_quotes_quote_number_unique` (`quote_number`),
  ADD KEY `crm_quotes_lead_id_foreign` (`lead_id`),
  ADD KEY `crm_quotes_corporate_account_id_foreign` (`corporate_account_id`),
  ADD KEY `crm_quotes_generated_by_foreign` (`generated_by`),
  ADD KEY `crm_quotes_tenant_id_index` (`tenant_id`),
  ADD KEY `crm_quotes_quote_number_index` (`quote_number`),
  ADD KEY `crm_quotes_status_index` (`status`);

--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customers_phone_index` (`phone`),
  ADD KEY `customers_email_index` (`email`),
  ADD KEY `customers_tenant_id_index` (`tenant_id`),
  ADD KEY `customers_user_id_index` (`user_id`);

--
-- Indexes for table `customer_surveys`
--
ALTER TABLE `customer_surveys`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customer_surveys_corporate_account_id_index` (`corporate_account_id`);

--
-- Indexes for table `daily_analytics`
--
ALTER TABLE `daily_analytics`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `daily_analytics_tenant_id_analytics_date_unique` (`tenant_id`,`analytics_date`),
  ADD KEY `daily_analytics_tenant_id_index` (`tenant_id`),
  ADD KEY `daily_analytics_analytics_date_index` (`analytics_date`);

--
-- Indexes for table `department_budgets`
--
ALTER TABLE `department_budgets`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `dept_budget_unique` (`corporate_account_id`,`department_name`,`month`,`year`),
  ADD KEY `department_budgets_corporate_account_id_index` (`corporate_account_id`);

--
-- Indexes for table `dispatcher_shifts`
--
ALTER TABLE `dispatcher_shifts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `dispatcher_shifts_tenant_id_index` (`tenant_id`),
  ADD KEY `dispatcher_shifts_dispatcher_id_index` (`dispatcher_id`);

--
-- Indexes for table `disputes`
--
ALTER TABLE `disputes`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `disputes_dispute_number_unique` (`dispute_number`),
  ADD KEY `disputes_booking_id_foreign` (`booking_id`),
  ADD KEY `disputes_reported_by_id_foreign` (`reported_by_id`),
  ADD KEY `disputes_reported_against_id_foreign` (`reported_against_id`),
  ADD KEY `disputes_tenant_id_index` (`tenant_id`),
  ADD KEY `disputes_status_index` (`status`);

--
-- Indexes for table `documents`
--
ALTER TABLE `documents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `documents_uploaded_by_foreign` (`uploaded_by`),
  ADD KEY `documents_verified_by_foreign` (`verified_by`),
  ADD KEY `documents_tenant_id_index` (`tenant_id`),
  ADD KEY `documents_owner_type_index` (`owner_type`),
  ADD KEY `documents_document_type_index` (`document_type`);

--
-- Indexes for table `feature_toggles`
--
ALTER TABLE `feature_toggles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `feature_toggles_tenant_id_feature_name_unique` (`tenant_id`,`feature_name`),
  ADD KEY `feature_toggles_tenant_id_index` (`tenant_id`);

--
-- Indexes for table `health_scores`
--
ALTER TABLE `health_scores`
  ADD PRIMARY KEY (`id`),
  ADD KEY `health_scores_created_by_foreign` (`created_by`),
  ADD KEY `health_scores_tenant_id_index` (`tenant_id`),
  ADD KEY `health_scores_customer_id_index` (`customer_id`),
  ADD KEY `health_scores_status_index` (`status`),
  ADD KEY `health_scores_overall_score_index` (`overall_score`),
  ADD KEY `health_scores_created_at_index` (`created_at`);

--
-- Indexes for table `interactions`
--
ALTER TABLE `interactions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `interactions_created_by_foreign` (`created_by`),
  ADD KEY `interactions_tenant_id_index` (`tenant_id`),
  ADD KEY `interactions_customer_id_index` (`customer_id`),
  ADD KEY `interactions_status_index` (`status`),
  ADD KEY `interactions_priority_index` (`priority`),
  ADD KEY `interactions_created_at_index` (`created_at`);

--
-- Indexes for table `invoices`
--
ALTER TABLE `invoices`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `invoices_invoice_number_unique` (`invoice_number`),
  ADD KEY `invoices_tenant_id_index` (`tenant_id`),
  ADD KEY `invoices_status_index` (`status`);

--
-- Indexes for table `marketing_campaigns`
--
ALTER TABLE `marketing_campaigns`
  ADD PRIMARY KEY (`id`),
  ADD KEY `marketing_campaigns_corporate_account_id_index` (`corporate_account_id`),
  ADD KEY `marketing_campaigns_status_index` (`status`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `operators`
--
ALTER TABLE `operators`
  ADD PRIMARY KEY (`id`),
  ADD KEY `operators_tenant_id_index` (`tenant_id`),
  ADD KEY `operators_status_index` (`status`),
  ADD KEY `operators_user_id_index` (`user_id`);

--
-- Indexes for table `partners`
--
ALTER TABLE `partners`
  ADD PRIMARY KEY (`id`),
  ADD KEY `partners_user_id_foreign` (`user_id`),
  ADD KEY `partners_tenant_id_index` (`tenant_id`),
  ADD KEY `partners_status_index` (`status`);

--
-- Indexes for table `partner_staff`
--
ALTER TABLE `partner_staff`
  ADD PRIMARY KEY (`id`),
  ADD KEY `partner_staff_user_id_foreign` (`user_id`),
  ADD KEY `partner_staff_partner_id_index` (`partner_id`);

--
-- Indexes for table `passengers`
--
ALTER TABLE `passengers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `passengers_user_id_foreign` (`user_id`),
  ADD KEY `passengers_tenant_id_index` (`tenant_id`),
  ADD KEY `passengers_status_index` (`status`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `payments_tenant_id_index` (`tenant_id`),
  ADD KEY `payments_booking_id_index` (`booking_id`),
  ADD KEY `payments_status_index` (`status`),
  ADD KEY `payments_created_at_index` (`created_at`);

--
-- Indexes for table `payouts`
--
ALTER TABLE `payouts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `payouts_payout_number_unique` (`payout_number`),
  ADD KEY `payouts_tenant_id_index` (`tenant_id`),
  ADD KEY `payouts_recipient_type_index` (`recipient_type`),
  ADD KEY `payouts_status_index` (`status`);

--
-- Indexes for table `performance_metrics`
--
ALTER TABLE `performance_metrics`
  ADD PRIMARY KEY (`id`),
  ADD KEY `performance_metrics_tenant_id_index` (`tenant_id`),
  ADD KEY `performance_metrics_metric_type_index` (`metric_type`);

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `permissions_role_id_permission_name_unique` (`role_id`,`permission_name`),
  ADD KEY `permissions_role_id_index` (`role_id`);

--
-- Indexes for table `rfq_requests`
--
ALTER TABLE `rfq_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `rfq_requests_rfq_number_unique` (`rfq_number`),
  ADD KEY `rfq_requests_tenant_id_index` (`tenant_id`),
  ADD KEY `rfq_requests_status_index` (`status`),
  ADD KEY `rfq_requests_rfq_number_index` (`rfq_number`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `roles_tenant_id_name_unique` (`tenant_id`,`name`),
  ADD KEY `roles_tenant_id_index` (`tenant_id`);

--
-- Indexes for table `saved_locations`
--
ALTER TABLE `saved_locations`
  ADD PRIMARY KEY (`id`),
  ADD KEY `saved_locations_passenger_id_index` (`passenger_id`);

--
-- Indexes for table `segments`
--
ALTER TABLE `segments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `segments_tenant_id_index` (`tenant_id`),
  ADD KEY `segments_created_by_index` (`created_by`),
  ADD KEY `segments_created_at_index` (`created_at`);

--
-- Indexes for table `segment_criteria`
--
ALTER TABLE `segment_criteria`
  ADD PRIMARY KEY (`id`),
  ADD KEY `segment_criteria_segment_id_index` (`segment_id`),
  ADD KEY `segment_criteria_tenant_id_index` (`tenant_id`);

--
-- Indexes for table `server_status`
--
ALTER TABLE `server_status`
  ADD PRIMARY KEY (`id`),
  ADD KEY `server_status_server_name_index` (`server_name`),
  ADD KEY `server_status_last_check_index` (`last_check`);

--
-- Indexes for table `sla_metrics`
--
ALTER TABLE `sla_metrics`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sla_metrics_tenant_id_index` (`tenant_id`),
  ADD KEY `sla_metrics_booking_id_index` (`booking_id`);

--
-- Indexes for table `sla_violations`
--
ALTER TABLE `sla_violations`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sla_violations_booking_id_foreign` (`booking_id`),
  ADD KEY `sla_violations_sla_metric_id_foreign` (`sla_metric_id`),
  ADD KEY `sla_violations_tenant_id_index` (`tenant_id`),
  ADD KEY `sla_violations_status_index` (`status`);

--
-- Indexes for table `subscription_plans`
--
ALTER TABLE `subscription_plans`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `subscription_plans_plan_name_unique` (`plan_name`);

--
-- Indexes for table `survey_responses`
--
ALTER TABLE `survey_responses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `survey_responses_survey_id_index` (`survey_id`);

--
-- Indexes for table `system_metrics`
--
ALTER TABLE `system_metrics`
  ADD PRIMARY KEY (`id`),
  ADD KEY `system_metrics_metric_name_index` (`metric_name`),
  ADD KEY `system_metrics_created_at_index` (`created_at`);

--
-- Indexes for table `tenants`
--
ALTER TABLE `tenants`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `tenants_slug_unique` (`slug`),
  ADD KEY `tenants_slug_index` (`slug`),
  ADD KEY `tenants_status_index` (`status`),
  ADD KEY `tenants_created_at_index` (`created_at`),
  ADD KEY `tenants_admin_user_id_foreign` (`admin_user_id`);

--
-- Indexes for table `travel_policies`
--
ALTER TABLE `travel_policies`
  ADD PRIMARY KEY (`id`),
  ADD KEY `travel_policies_corporate_account_id_index` (`corporate_account_id`);

--
-- Indexes for table `trip_ratings`
--
ALTER TABLE `trip_ratings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `trip_ratings_booking_id_unique` (`booking_id`);

--
-- Indexes for table `trip_tracking`
--
ALTER TABLE `trip_tracking`
  ADD PRIMARY KEY (`id`),
  ADD KEY `trip_tracking_booking_id_index` (`booking_id`),
  ADD KEY `trip_tracking_created_at_index` (`created_at`);

--
-- Indexes for table `user_profiles`
--
ALTER TABLE `user_profiles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `user_profiles_user_id_unique` (`user_id`);

--
-- Indexes for table `user_roles`
--
ALTER TABLE `user_roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `user_roles_user_id_role_id_tenant_id_unique` (`user_id`,`role_id`,`tenant_id`),
  ADD KEY `user_roles_tenant_id_foreign` (`tenant_id`),
  ADD KEY `user_roles_assigned_by_foreign` (`assigned_by`),
  ADD KEY `user_roles_user_id_index` (`user_id`),
  ADD KEY `user_roles_role_id_index` (`role_id`);

--
-- Indexes for table `vehicles`
--
ALTER TABLE `vehicles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `vehicles_registration_number_unique` (`registration_number`),
  ADD KEY `vehicles_driver_id_foreign` (`driver_id`),
  ADD KEY `vehicles_tenant_id_index` (`tenant_id`),
  ADD KEY `vehicles_operator_id_index` (`operator_id`),
  ADD KEY `vehicles_status_index` (`status`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `activities`
--
ALTER TABLE `activities`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `affiliate_leads`
--
ALTER TABLE `affiliate_leads`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `audit_logs`
--
ALTER TABLE `audit_logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `bids`
--
ALTER TABLE `bids`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `bid_attachments`
--
ALTER TABLE `bid_attachments`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `bookings`
--
ALTER TABLE `bookings`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `booking_approvals`
--
ALTER TABLE `booking_approvals`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `commissions`
--
ALTER TABLE `commissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `communication_logs`
--
ALTER TABLE `communication_logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `compliance_checks`
--
ALTER TABLE `compliance_checks`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `corporate_accounts`
--
ALTER TABLE `corporate_accounts`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- AUTO_INCREMENT for table `corporate_clients`
--
ALTER TABLE `corporate_clients`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `corporate_travelers`
--
ALTER TABLE `corporate_travelers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `crm_contracts`
--
ALTER TABLE `crm_contracts`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `crm_leads`
--
ALTER TABLE `crm_leads`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;

--
-- AUTO_INCREMENT for table `crm_quotes`
--
ALTER TABLE `crm_quotes`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;

--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `customer_surveys`
--
ALTER TABLE `customer_surveys`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `daily_analytics`
--
ALTER TABLE `daily_analytics`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `department_budgets`
--
ALTER TABLE `department_budgets`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `dispatcher_shifts`
--
ALTER TABLE `dispatcher_shifts`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `disputes`
--
ALTER TABLE `disputes`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `documents`
--
ALTER TABLE `documents`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `feature_toggles`
--
ALTER TABLE `feature_toggles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `health_scores`
--
ALTER TABLE `health_scores`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `interactions`
--
ALTER TABLE `interactions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `invoices`
--
ALTER TABLE `invoices`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `marketing_campaigns`
--
ALTER TABLE `marketing_campaigns`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=73;

--
-- AUTO_INCREMENT for table `operators`
--
ALTER TABLE `operators`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `partners`
--
ALTER TABLE `partners`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `partner_staff`
--
ALTER TABLE `partner_staff`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `passengers`
--
ALTER TABLE `passengers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payouts`
--
ALTER TABLE `payouts`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `performance_metrics`
--
ALTER TABLE `performance_metrics`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rfq_requests`
--
ALTER TABLE `rfq_requests`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `saved_locations`
--
ALTER TABLE `saved_locations`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `segments`
--
ALTER TABLE `segments`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `segment_criteria`
--
ALTER TABLE `segment_criteria`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `server_status`
--
ALTER TABLE `server_status`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sla_metrics`
--
ALTER TABLE `sla_metrics`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sla_violations`
--
ALTER TABLE `sla_violations`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `subscription_plans`
--
ALTER TABLE `subscription_plans`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `survey_responses`
--
ALTER TABLE `survey_responses`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `system_metrics`
--
ALTER TABLE `system_metrics`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `tenants`
--
ALTER TABLE `tenants`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `travel_policies`
--
ALTER TABLE `travel_policies`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `trip_ratings`
--
ALTER TABLE `trip_ratings`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `trip_tracking`
--
ALTER TABLE `trip_tracking`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_profiles`
--
ALTER TABLE `user_profiles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_roles`
--
ALTER TABLE `user_roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `vehicles`
--
ALTER TABLE `vehicles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `activities`
--
ALTER TABLE `activities`
  ADD CONSTRAINT `activities_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `activities_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `activities_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `affiliate_leads`
--
ALTER TABLE `affiliate_leads`
  ADD CONSTRAINT `affiliate_leads_affiliate_id_foreign` FOREIGN KEY (`affiliate_id`) REFERENCES `affiliates` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `affiliate_leads_converted_booking_id_foreign` FOREIGN KEY (`converted_booking_id`) REFERENCES `bookings` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `audit_logs`
--
ALTER TABLE `audit_logs`
  ADD CONSTRAINT `audit_logs_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `audit_logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `bids`
--
ALTER TABLE `bids`
  ADD CONSTRAINT `bids_reviewed_by_foreign` FOREIGN KEY (`reviewed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `bids_rfq_id_foreign` FOREIGN KEY (`rfq_id`) REFERENCES `rfq_requests` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `bids_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `bid_attachments`
--
ALTER TABLE `bid_attachments`
  ADD CONSTRAINT `bid_attachments_bid_id_foreign` FOREIGN KEY (`bid_id`) REFERENCES `bids` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `bookings`
--
ALTER TABLE `bookings`
  ADD CONSTRAINT `bookings_driver_id_foreign` FOREIGN KEY (`driver_id`) REFERENCES `drivers` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `bookings_operator_id_foreign` FOREIGN KEY (`operator_id`) REFERENCES `operators` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `bookings_passenger_id_foreign` FOREIGN KEY (`passenger_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `bookings_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `bookings_vehicle_id_foreign` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `booking_approvals`
--
ALTER TABLE `booking_approvals`
  ADD CONSTRAINT `booking_approvals_approver_id_foreign` FOREIGN KEY (`approver_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `booking_approvals_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `booking_approvals_corporate_traveler_id_foreign` FOREIGN KEY (`corporate_traveler_id`) REFERENCES `corporate_travelers` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `commissions`
--
ALTER TABLE `commissions`
  ADD CONSTRAINT `commissions_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `commissions_payout_id_foreign` FOREIGN KEY (`payout_id`) REFERENCES `payouts` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `commissions_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `communication_logs`
--
ALTER TABLE `communication_logs`
  ADD CONSTRAINT `communication_logs_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `communication_logs_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `communication_logs_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `compliance_checks`
--
ALTER TABLE `compliance_checks`
  ADD CONSTRAINT `compliance_checks_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `corporate_accounts`
--
ALTER TABLE `corporate_accounts`
  ADD CONSTRAINT `corporate_accounts_account_manager_id_foreign` FOREIGN KEY (`account_manager_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `corporate_accounts_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `corporate_accounts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `corporate_clients`
--
ALTER TABLE `corporate_clients`
  ADD CONSTRAINT `corporate_clients_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `corporate_travelers`
--
ALTER TABLE `corporate_travelers`
  ADD CONSTRAINT `corporate_travelers_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `corporate_travelers_manager_id_foreign` FOREIGN KEY (`manager_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `corporate_travelers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `crm_contracts`
--
ALTER TABLE `crm_contracts`
  ADD CONSTRAINT `crm_contracts_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `crm_contracts_quote_id_foreign` FOREIGN KEY (`quote_id`) REFERENCES `crm_quotes` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `crm_contracts_signed_by_foreign` FOREIGN KEY (`signed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `crm_contracts_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `crm_leads`
--
ALTER TABLE `crm_leads`
  ADD CONSTRAINT `crm_leads_assigned_to_foreign` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `crm_leads_converted_to_account_id_foreign` FOREIGN KEY (`converted_to_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `crm_leads_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `crm_quotes`
--
ALTER TABLE `crm_quotes`
  ADD CONSTRAINT `crm_quotes_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `crm_quotes_generated_by_foreign` FOREIGN KEY (`generated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `crm_quotes_lead_id_foreign` FOREIGN KEY (`lead_id`) REFERENCES `crm_leads` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `crm_quotes_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `customers`
--
ALTER TABLE `customers`
  ADD CONSTRAINT `customers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `customer_surveys`
--
ALTER TABLE `customer_surveys`
  ADD CONSTRAINT `customer_surveys_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `daily_analytics`
--
ALTER TABLE `daily_analytics`
  ADD CONSTRAINT `daily_analytics_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `department_budgets`
--
ALTER TABLE `department_budgets`
  ADD CONSTRAINT `department_budgets_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `dispatcher_shifts`
--
ALTER TABLE `dispatcher_shifts`
  ADD CONSTRAINT `dispatcher_shifts_dispatcher_id_foreign` FOREIGN KEY (`dispatcher_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `dispatcher_shifts_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `disputes`
--
ALTER TABLE `disputes`
  ADD CONSTRAINT `disputes_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `disputes_reported_against_id_foreign` FOREIGN KEY (`reported_against_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `disputes_reported_by_id_foreign` FOREIGN KEY (`reported_by_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `disputes_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `documents`
--
ALTER TABLE `documents`
  ADD CONSTRAINT `documents_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `documents_uploaded_by_foreign` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `documents_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `feature_toggles`
--
ALTER TABLE `feature_toggles`
  ADD CONSTRAINT `feature_toggles_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `health_scores`
--
ALTER TABLE `health_scores`
  ADD CONSTRAINT `health_scores_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `health_scores_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `interactions`
--
ALTER TABLE `interactions`
  ADD CONSTRAINT `interactions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `interactions_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `interactions_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `invoices`
--
ALTER TABLE `invoices`
  ADD CONSTRAINT `invoices_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `marketing_campaigns`
--
ALTER TABLE `marketing_campaigns`
  ADD CONSTRAINT `marketing_campaigns_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `operators`
--
ALTER TABLE `operators`
  ADD CONSTRAINT `operators_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `operators_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `partners`
--
ALTER TABLE `partners`
  ADD CONSTRAINT `partners_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `partners_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `partner_staff`
--
ALTER TABLE `partner_staff`
  ADD CONSTRAINT `partner_staff_partner_id_foreign` FOREIGN KEY (`partner_id`) REFERENCES `partners` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `partner_staff_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `passengers`
--
ALTER TABLE `passengers`
  ADD CONSTRAINT `passengers_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `passengers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `payments_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payouts`
--
ALTER TABLE `payouts`
  ADD CONSTRAINT `payouts_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `performance_metrics`
--
ALTER TABLE `performance_metrics`
  ADD CONSTRAINT `performance_metrics_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `permissions`
--
ALTER TABLE `permissions`
  ADD CONSTRAINT `permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `rfq_requests`
--
ALTER TABLE `rfq_requests`
  ADD CONSTRAINT `rfq_requests_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `roles`
--
ALTER TABLE `roles`
  ADD CONSTRAINT `roles_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `saved_locations`
--
ALTER TABLE `saved_locations`
  ADD CONSTRAINT `saved_locations_passenger_id_foreign` FOREIGN KEY (`passenger_id`) REFERENCES `passengers` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `segments`
--
ALTER TABLE `segments`
  ADD CONSTRAINT `segments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `segments_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `segment_criteria`
--
ALTER TABLE `segment_criteria`
  ADD CONSTRAINT `segment_criteria_segment_id_foreign` FOREIGN KEY (`segment_id`) REFERENCES `segments` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `segment_criteria_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `sla_metrics`
--
ALTER TABLE `sla_metrics`
  ADD CONSTRAINT `sla_metrics_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `sla_metrics_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `sla_violations`
--
ALTER TABLE `sla_violations`
  ADD CONSTRAINT `sla_violations_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `sla_violations_sla_metric_id_foreign` FOREIGN KEY (`sla_metric_id`) REFERENCES `sla_metrics` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `sla_violations_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `survey_responses`
--
ALTER TABLE `survey_responses`
  ADD CONSTRAINT `survey_responses_survey_id_foreign` FOREIGN KEY (`survey_id`) REFERENCES `customer_surveys` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `tenants`
--
ALTER TABLE `tenants`
  ADD CONSTRAINT `tenants_admin_user_id_foreign` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `travel_policies`
--
ALTER TABLE `travel_policies`
  ADD CONSTRAINT `travel_policies_corporate_account_id_foreign` FOREIGN KEY (`corporate_account_id`) REFERENCES `corporate_accounts` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `trip_ratings`
--
ALTER TABLE `trip_ratings`
  ADD CONSTRAINT `trip_ratings_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `trip_tracking`
--
ALTER TABLE `trip_tracking`
  ADD CONSTRAINT `trip_tracking_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE;
COMMIT;

