/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `access_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `access_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `principal_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'admin, scanner, customer, system',
  `principal_id` bigint unsigned DEFAULT NULL COMMENT 'ID of the principal (null for anonymous)',
  `principal_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Denormalized name for display',
  `action` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Permission key checked e.g. seats.block',
  `resource_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Model type e.g. Order, Seat',
  `resource_id` bigint unsigned DEFAULT NULL COMMENT 'ID of the resource',
  `resource_label` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Human-readable resource label',
  `decision` enum('granted','denied') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Access decision',
  `denial_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Why access was denied',
  `decision_source` enum('role','override_grant','override_revoke','inactive','no_permission') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'What determined the decision',
  `override_used_id` bigint unsigned DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'IPv4 or IPv6',
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `request_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Correlation ID for request tracing',
  `route` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Route name or URI',
  `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'HTTP method',
  `metadata` json DEFAULT NULL COMMENT 'Additional context data',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `access_logs_override_used_id_foreign` (`override_used_id`),
  KEY `idx_principal_access` (`principal_type`,`principal_id`,`created_at`),
  KEY `idx_decision_time` (`decision`,`created_at`),
  KEY `idx_resource_access` (`resource_type`,`resource_id`,`created_at`),
  KEY `idx_action_time` (`action`,`created_at`),
  KEY `idx_ip_address` (`ip_address`),
  KEY `idx_request_id` (`request_id`),
  KEY `idx_created_at` (`created_at`),
  CONSTRAINT `access_logs_override_used_id_foreign` FOREIGN KEY (`override_used_id`) REFERENCES `permission_overrides` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `account_setup_invitations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `account_setup_invitations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `first_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `setup_token` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `invitation_email_tracking_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `invitation_email_sent_at` timestamp NULL DEFAULT NULL,
  `invitation_email_opened_at` timestamp NULL DEFAULT NULL,
  `invitation_email_clicked_at` timestamp NULL DEFAULT NULL,
  `link_clicked` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'setup_account, decline, unsubscribe',
  `email_send_attempts` int NOT NULL DEFAULT '0',
  `email_send_failed` tinyint(1) NOT NULL DEFAULT '0',
  `email_send_error` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `bounce_type` enum('hard','soft','none') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'none',
  `bounce_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `bounced_at` timestamp NULL DEFAULT NULL,
  `soft_bounce_count` int NOT NULL DEFAULT '0',
  `status` enum('pending','completed','expired','declined','bounced') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `expires_at` timestamp NOT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `unsubscribed_at` timestamp NULL DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `campaign_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `source` enum('csv','bulk','api','manual','scheduled','bulk_import') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'manual',
  `target_filter` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'For bulk campaigns: all, high_value, repeat_customers',
  `campaign_status` enum('scheduled','active','paused','completed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT 'Current campaign lifecycle state',
  `batch_config` json DEFAULT NULL COMMENT 'Stores: batch_size, batch_delay, max_per_hour',
  `progress_data` json DEFAULT NULL COMMENT 'Stores: current_batch, total_batches, sent, pending, failed, skipped',
  `paused_at` timestamp NULL DEFAULT NULL,
  `resumed_at` timestamp NULL DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `sent_by` bigint unsigned DEFAULT NULL,
  `decline_reason` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `account_setup_invitations_setup_token_unique` (`setup_token`),
  KEY `account_setup_invitations_created_at_index` (`created_at`),
  KEY `account_setup_invitations_status_expires_at_index` (`status`,`expires_at`),
  KEY `account_setup_invitations_email_index` (`email`),
  KEY `account_setup_invitations_status_index` (`status`),
  KEY `account_setup_invitations_expires_at_index` (`expires_at`),
  KEY `account_setup_invitations_user_id_index` (`user_id`),
  KEY `idx_campaign_status` (`campaign_status`),
  KEY `idx_source` (`source`),
  KEY `idx_campaign_name` (`campaign_name`),
  KEY `idx_created_at` (`created_at`),
  KEY `idx_invitation_email_tracking_id` (`invitation_email_tracking_id`),
  KEY `idx_invitation_email_sent_at` (`invitation_email_sent_at`),
  KEY `idx_bounced_at` (`bounced_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `act_sponsor_photos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `act_sponsor_photos` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `acts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `acts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `no_of_perticipant` int NOT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `video` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `added_by` bigint unsigned DEFAULT NULL,
  `deleted_by` bigint unsigned DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1',
  `is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT 'allow only 0 / 1 for true and false',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `acts_event_id_foreign` (`event_id`),
  KEY `acts_added_by_foreign` (`added_by`),
  KEY `acts_deleted_by_foreign` (`deleted_by`),
  CONSTRAINT `acts_added_by_foreign` FOREIGN KEY (`added_by`) REFERENCES `users` (`id`),
  CONSTRAINT `acts_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`),
  CONSTRAINT `acts_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `admin_password_resets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `admin_password_resets` (
  `email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  KEY `admin_password_resets_email_index` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `admin_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `admin_permissions` (
  `admin_id` bigint unsigned NOT NULL,
  `permission_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`admin_id`,`permission_id`),
  KEY `idx_admin_id` (`admin_id`),
  CONSTRAINT `admin_permissions_admin_id_foreign` FOREIGN KEY (`admin_id`) REFERENCES `admins` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `admin_roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `admin_roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `display_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `permissions` json NOT NULL,
  `is_system` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `admin_roles_name_unique` (`name`),
  KEY `admin_roles_is_active_index` (`is_active`),
  KEY `admin_roles_is_system_index` (`is_system`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `admins`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `admins` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `backup_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `password_changed_at` timestamp NULL DEFAULT NULL,
  `profile_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `role_id` bigint unsigned DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `last_login_at` timestamp NULL DEFAULT NULL,
  `last_login_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_action_at` timestamp NULL DEFAULT NULL,
  `last_action_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `suspension_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `suspended_at` timestamp NULL DEFAULT NULL,
  `suspended_by` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `admins_username_unique` (`username`),
  UNIQUE KEY `admins_email_unique` (`email`),
  KEY `admins_is_active_index` (`is_active`),
  KEY `admins_role_id_index` (`role_id`),
  KEY `admins_email_index` (`email`),
  KEY `admins_username_index` (`username`),
  KEY `admins_suspended_by_foreign` (`suspended_by`),
  KEY `admins_created_by_foreign` (`created_by`),
  KEY `admins_updated_by_foreign` (`updated_by`),
  KEY `admins_backup_email_index` (`backup_email`),
  KEY `admins_suspended_at_index` (`suspended_at`),
  KEY `admins_last_action_at_index` (`last_action_at`),
  CONSTRAINT `admins_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  CONSTRAINT `admins_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `admin_roles` (`id`) ON DELETE SET NULL,
  CONSTRAINT `admins_suspended_by_foreign` FOREIGN KEY (`suspended_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  CONSTRAINT `admins_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `analytics_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `analytics_events` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned DEFAULT NULL,
  `session_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `analytics_events_event_id_event_type_created_at_index` (`event_id`,`event_type`,`created_at`),
  KEY `analytics_events_session_id_created_at_index` (`session_id`,`created_at`),
  KEY `analytics_events_session_id_index` (`session_id`),
  KEY `analytics_events_event_type_index` (`event_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `archived_event_artist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `archived_event_artist` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `archived_event_id` bigint unsigned NOT NULL,
  `artist_id` bigint unsigned NOT NULL,
  `display_order` int NOT NULL DEFAULT '0',
  `role` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_archived_event_artist` (`archived_event_id`,`artist_id`),
  KEY `archived_event_artist_archived_event_id_index` (`archived_event_id`),
  KEY `archived_event_artist_artist_id_index` (`artist_id`),
  CONSTRAINT `archived_event_artist_archived_event_id_foreign` FOREIGN KEY (`archived_event_id`) REFERENCES `archived_events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `archived_event_artist_artist_id_foreign` FOREIGN KEY (`artist_id`) REFERENCES `artists` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `archived_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `archived_events` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `subtitle` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `venue_name` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `venue_city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'London',
  `venue_country` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'United Kingdom',
  `event_date` date DEFAULT NULL,
  `event_year` year DEFAULT NULL,
  `is_published` tinyint(1) NOT NULL DEFAULT '1',
  `is_featured` tinyint(1) NOT NULL DEFAULT '0',
  `display_order` int NOT NULL DEFAULT '0',
  `legacy_event_id` int unsigned DEFAULT NULL,
  `legacy_metadata` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `archived_events_slug_unique` (`slug`),
  UNIQUE KEY `archived_events_legacy_event_id_unique` (`legacy_event_id`),
  KEY `archived_events_slug_index` (`slug`),
  KEY `archived_events_event_year_index` (`event_year`),
  KEY `archived_events_is_published_display_order_index` (`is_published`,`display_order`),
  KEY `archived_events_legacy_event_id_index` (`legacy_event_id`),
  KEY `archived_events_is_featured_index` (`is_featured`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `artist_event`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `artist_event` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `artist_id` bigint unsigned NOT NULL,
  `event_id` bigint unsigned NOT NULL,
  `display_order` int NOT NULL DEFAULT '0',
  `role` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'performer',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `artist_event_artist_id_event_id_unique` (`artist_id`,`event_id`),
  KEY `artist_event_event_id_display_order_index` (`event_id`,`display_order`),
  CONSTRAINT `artist_event_artist_id_foreign` FOREIGN KEY (`artist_id`) REFERENCES `artists` (`id`) ON DELETE CASCADE,
  CONSTRAINT `artist_event_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `artists`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `artists` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `legacy_artist_id` int unsigned DEFAULT NULL COMMENT 'ID from legacy globalgala_inspect.infrecord table',
  `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name_arabic` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Artist name in Arabic',
  `slug` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `bio` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `bio_arabic` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Biography in Arabic',
  `profile_image` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `instagram_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `twitter_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `facebook_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `youtube_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `spotify_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `legacy_metadata` json DEFAULT NULL COMMENT 'JSON storage for legacy system data (dates, fields, etc.)',
  `is_published` tinyint(1) NOT NULL DEFAULT '0',
  `is_featured` tinyint(1) NOT NULL DEFAULT '0',
  `is_legacy` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indicates if artist migrated from legacy system',
  `display_order` int unsigned NOT NULL DEFAULT '0' COMMENT 'Manual sorting order for artist listings',
  `status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `artists_slug_unique` (`slug`),
  KEY `artists_slug_index` (`slug`),
  KEY `artists_status_index` (`status`),
  KEY `artists_is_published_index` (`is_published`),
  KEY `artists_legacy_artist_id_index` (`legacy_artist_id`),
  KEY `artists_is_legacy_index` (`is_legacy`),
  KEY `artists_display_order_index` (`display_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `banners`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `banners` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` int NOT NULL DEFAULT '1',
  `order` int NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `batch_jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `batch_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `batch_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('initializing','processing','completed','failed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'initializing',
  `total_items` int NOT NULL DEFAULT '0',
  `processed_items` int NOT NULL DEFAULT '0',
  `failed_items` int NOT NULL DEFAULT '0',
  `chunk_size` int NOT NULL DEFAULT '100',
  `progress_percentage` decimal(5,2) NOT NULL DEFAULT '0.00',
  `options` json DEFAULT NULL,
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `result_summary` json DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `batch_jobs_batch_id_unique` (`batch_id`),
  KEY `batch_jobs_batch_id_index` (`batch_id`),
  KEY `batch_jobs_status_index` (`status`),
  KEY `batch_jobs_created_at_index` (`created_at`),
  KEY `batch_jobs_status_created_at_index` (`status`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `blog_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `blog_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` int NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `blogs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `blogs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `category_id` int NOT NULL,
  `sub_category_id` int DEFAULT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_published` int NOT NULL,
  `show_on_homepage` int NOT NULL,
  `blog_views` int NOT NULL DEFAULT '0',
  `status` int NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `booking_access_code_sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `booking_access_code_sessions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `code_id` bigint unsigned NOT NULL,
  `session_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Browser UUID from frontend',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'For analytics',
  `used_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `booking_access_code_sessions_code_id_session_id_unique` (`code_id`,`session_id`),
  KEY `booking_access_code_sessions_code_id_index` (`code_id`),
  KEY `booking_access_code_sessions_session_id_index` (`session_id`),
  CONSTRAINT `booking_access_code_sessions_code_id_foreign` FOREIGN KEY (`code_id`) REFERENCES `booking_access_codes` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `booking_access_codes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `booking_access_codes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '8-char unpredictable code',
  `event_id` bigint unsigned DEFAULT NULL COMMENT 'NULL = works for all events',
  `max_sessions` tinyint unsigned NOT NULL DEFAULT '2' COMMENT 'Max different sessions allowed',
  `expires_at` timestamp NULL DEFAULT NULL COMMENT 'NULL = never expires',
  `created_by` bigint unsigned DEFAULT NULL COMMENT 'Admin user ID',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Admin reference notes',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `booking_access_codes_code_unique` (`code`),
  KEY `booking_access_codes_code_index` (`code`),
  KEY `booking_access_codes_expires_at_index` (`expires_at`),
  KEY `booking_access_codes_event_id_index` (`event_id`),
  KEY `booking_access_codes_created_by_foreign` (`created_by`),
  CONSTRAINT `booking_access_codes_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `booking_access_codes_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `bulk_ticket_status_batches`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `bulk_ticket_status_batches` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `batch_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `operation_type` enum('block','unblock','shadow_sold','activate') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('initializing','processing','completed','failed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'initializing',
  `event_id` bigint unsigned DEFAULT NULL,
  `total_seats` int NOT NULL DEFAULT '0',
  `processed_seats` int NOT NULL DEFAULT '0',
  `successful_seats` int NOT NULL DEFAULT '0',
  `failed_seats` int NOT NULL DEFAULT '0',
  `failed_seat_ids` json DEFAULT NULL,
  `errors` json DEFAULT NULL,
  `csv_filename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `bulk_ticket_status_batches_batch_id_unique` (`batch_id`),
  KEY `bulk_ticket_status_batches_created_at_index` (`created_at`),
  KEY `bulk_ticket_status_batches_status_created_at_index` (`status`,`created_at`),
  KEY `bulk_ticket_status_batches_operation_type_index` (`operation_type`),
  KEY `bulk_ticket_status_batches_status_index` (`status`),
  KEY `bulk_ticket_status_batches_event_id_index` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache` (
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache_locks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache_locks` (
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `campaign_audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `campaign_audit_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `campaign_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_type` enum('created','started','paused','resumed','cancelled','completed','settings_modified','invitation_sent','invitation_failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Type of campaign event',
  `user_id` bigint unsigned DEFAULT NULL COMMENT 'Admin user ID',
  `user_email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Admin email for reference',
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `details` json DEFAULT NULL COMMENT 'Event-specific data',
  PRIMARY KEY (`id`),
  KEY `idx_audit_campaign_name` (`campaign_name`),
  KEY `idx_event_type` (`event_type`),
  KEY `idx_timestamp` (`timestamp`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `carts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `carts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` int DEFAULT NULL,
  `ip` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `seat_id` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `seat` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `quantity` int NOT NULL DEFAULT '1',
  `amount` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `zone` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `sub_cat` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `seat_color` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_cart_seat` (`event_id`,`seat_id`,`seat`),
  KEY `idx_user_event` (`user_id`,`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `chargebacks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `chargebacks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `payment_transaction_id` bigint unsigned DEFAULT NULL,
  `chargeback_amount` decimal(10,2) NOT NULL,
  `chargeback_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `dispute_status` enum('needs_response','received','under_review','evidence_required','evidence_submitted','won','lost','accepted','withdrawn') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT 'received',
  `gateway` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `gateway_dispute_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gateway_charge_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gateway_payment_intent_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `evidence_submitted_at` timestamp NULL DEFAULT NULL,
  `evidence_due_by` timestamp NULL DEFAULT NULL,
  `admin_notified_at` timestamp NULL DEFAULT NULL,
  `resolved_at` timestamp NULL DEFAULT NULL,
  `resolution_outcome` enum('won','lost','accepted','withdrawn') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gateway_response` json DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `chargebacks_order_id_dispute_status_index` (`order_id`,`dispute_status`),
  KEY `chargebacks_payment_transaction_id_index` (`payment_transaction_id`),
  KEY `chargebacks_gateway_dispute_id_index` (`gateway_dispute_id`),
  KEY `chargebacks_dispute_status_index` (`dispute_status`),
  KEY `chargebacks_created_at_index` (`created_at`),
  KEY `chargebacks_gateway_payment_intent_id_index` (`gateway_payment_intent_id`),
  CONSTRAINT `chargebacks_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `chargebacks_payment_transaction_id_foreign` FOREIGN KEY (`payment_transaction_id`) REFERENCES `payment_transactions` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `clubs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clubs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `contact_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `contact_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `contact_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `treasurer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `logo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `bank_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_active` tinyint NOT NULL DEFAULT '1' COMMENT 'allow only 0 / 1 for true and false',
  `is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT 'allow only 0 / 1 for true and false',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cms_files`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cms_files` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `filename` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `stored_filename` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `path` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `file_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `file_size` bigint unsigned DEFAULT NULL,
  `mime_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_image` tinyint(1) NOT NULL DEFAULT '0',
  `is_video` tinyint(1) NOT NULL DEFAULT '0',
  `size` bigint unsigned NOT NULL,
  `category` enum('email','blog','general') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'general',
  `tags` json DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_public` tinyint(1) NOT NULL DEFAULT '1',
  `uploaded_by` bigint unsigned DEFAULT NULL,
  `usage_count` int unsigned NOT NULL DEFAULT '0',
  `last_accessed_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `cms_files_stored_filename_unique` (`stored_filename`),
  KEY `cms_files_category_index` (`category`),
  KEY `cms_files_mime_type_index` (`mime_type`),
  KEY `cms_files_is_public_index` (`is_public`),
  KEY `cms_files_uploaded_by_index` (`uploaded_by`),
  KEY `cms_files_created_at_index` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `content_pages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `content_pages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `sort_order` int NOT NULL DEFAULT '0',
  `display_section` enum('header','footer','event_info','standalone') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'footer',
  `meta_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `meta_keywords` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `content_pages_slug_unique` (`slug`),
  KEY `content_pages_is_active_sort_order_index` (`is_active`,`sort_order`),
  KEY `content_pages_display_section_index` (`display_section`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contents` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` int NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `coupon_usage`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `coupon_usage` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `coupon_id` bigint unsigned DEFAULT NULL COMMENT 'Which coupon was used (nullable to preserve audit trail if coupon deleted)',
  `order_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Order ID (alphanumeric string from orders.order_id)',
  `customer_email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Customer email (for per-customer limit tracking)',
  `discount_applied` decimal(10,2) NOT NULL COMMENT 'Actual discount amount applied to this order',
  `original_subtotal` decimal(10,2) NOT NULL COMMENT 'Order subtotal before discount',
  `final_subtotal` decimal(10,2) NOT NULL COMMENT 'Order subtotal after discount',
  `event_id` bigint unsigned DEFAULT NULL COMMENT 'Which event this order was for',
  `seats_count` int NOT NULL COMMENT 'Number of seats/tickets in this order',
  `used_at` timestamp NOT NULL COMMENT 'When coupon was redeemed',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_coupon_order_unique` (`coupon_id`,`order_id`),
  KEY `coupon_usage_event_id_foreign` (`event_id`),
  KEY `idx_coupon` (`coupon_id`),
  KEY `idx_order` (`order_id`),
  KEY `idx_customer` (`customer_email`),
  KEY `idx_coupon_customer` (`coupon_id`,`customer_email`),
  KEY `idx_used_at` (`used_at`),
  CONSTRAINT `coupon_usage_coupon_id_foreign` FOREIGN KEY (`coupon_id`) REFERENCES `coupons` (`id`) ON DELETE SET NULL,
  CONSTRAINT `coupon_usage_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `coupons`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `coupons` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Coupon code: uppercase alphanumeric + hyphens only',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Admin description of coupon purpose',
  `discount_type` enum('percentage','fixed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'percentage: % off subtotal, fixed: € off subtotal',
  `discount_value` decimal(10,2) NOT NULL COMMENT 'Percentage (0-100) or fixed amount in euros',
  `applies_to` enum('all_events','specific_event') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'all_events' COMMENT 'Whether coupon applies globally or to specific event',
  `event_id` bigint unsigned DEFAULT NULL COMMENT 'If applies_to=specific_event, which event',
  `max_uses` int DEFAULT NULL COMMENT 'Maximum total uses (NULL = unlimited)',
  `uses_count` int NOT NULL DEFAULT '0' COMMENT 'Current usage count (incremented on each redemption)',
  `max_uses_per_customer` int NOT NULL DEFAULT '1' COMMENT 'Maximum uses per customer email',
  `min_order_value` decimal(10,2) DEFAULT NULL COMMENT 'Minimum subtotal required to apply coupon',
  `valid_from` datetime DEFAULT NULL COMMENT 'Coupon valid from this datetime (NULL = valid immediately)',
  `valid_until` datetime DEFAULT NULL COMMENT 'Coupon expires at this datetime (NULL = never expires)',
  `status` enum('active','inactive','expired') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT 'active: can be used, inactive: disabled by admin, expired: past valid_until',
  `created_by` bigint unsigned DEFAULT NULL COMMENT 'Admin user ID who created this coupon',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `coupons_code_unique` (`code`),
  KEY `coupons_created_by_foreign` (`created_by`),
  KEY `idx_code` (`code`),
  KEY `idx_status` (`status`),
  KEY `idx_valid_dates` (`valid_from`,`valid_until`),
  KEY `idx_event` (`event_id`),
  CONSTRAINT `coupons_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  CONSTRAINT `coupons_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `customer_profiles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `customer_profiles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `marketing_opt_in` tinyint(1) NOT NULL DEFAULT '0',
  `ticket_email_preference` enum('always','never','only_if_requested') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'always',
  `language` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'en',
  `timezone` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'UTC',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `customer_profiles_user_id_unique` (`user_id`),
  KEY `customer_profiles_user_id_index` (`user_id`),
  CONSTRAINT `customer_profiles_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `customers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `customers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `preferred_payment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `loyalty_points` int NOT NULL DEFAULT '0',
  `membership_tier` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_of_birth` date DEFAULT NULL,
  `preferences` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `customers_user_id_index` (`user_id`),
  KEY `customers_membership_tier_index` (`membership_tier`),
  CONSTRAINT `customers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `device_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `device_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Human-readable device name',
  `scanner_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Unique scanner identifier',
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'entry_scanner' COMMENT 'Device type: entry_scanner, manager_device, etc.',
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'SHA256 hash of actual token',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Device active status',
  `expires_at` timestamp NULL DEFAULT NULL COMMENT 'Token expiration time',
  `last_used_at` timestamp NULL DEFAULT NULL COMMENT 'Last successful authentication',
  `last_used_ip` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Last IP address used',
  `allowed_ips` json DEFAULT NULL COMMENT 'IP whitelist (CIDR supported)',
  `allowed_events` json DEFAULT NULL COMMENT 'Event IDs this device can access',
  `created_by` bigint unsigned DEFAULT NULL COMMENT 'Admin who created token',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Admin notes about device',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `device_tokens_scanner_id_unique` (`scanner_id`),
  UNIQUE KEY `device_tokens_token_unique` (`token`),
  KEY `device_tokens_scanner_id_index` (`scanner_id`),
  KEY `device_tokens_token_index` (`token`),
  KEY `device_tokens_is_active_expires_at_index` (`is_active`,`expires_at`),
  KEY `device_tokens_type_index` (`type`),
  KEY `device_tokens_created_by_foreign` (`created_by`),
  CONSTRAINT `device_tokens_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Entry staff device authentication tokens';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `donation_amounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `donation_amounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `amount` int NOT NULL,
  `status` tinyint NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_accounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `display_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `purpose` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'transactional, support, finance, system, etc.',
  `daily_send_limit` int NOT NULL DEFAULT '500',
  `hourly_send_limit` int NOT NULL DEFAULT '50',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `auto_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `reply_to_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_accounts_email_unique` (`email`),
  KEY `email_accounts_is_active_index` (`is_active`),
  KEY `email_accounts_purpose_is_active_index` (`purpose`,`is_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_delivery_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_delivery_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `event` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `timestamp` timestamp NULL DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `email_delivery_logs_order_id_index` (`order_id`),
  KEY `email_delivery_logs_event_index` (`event`),
  KEY `email_delivery_logs_order_timestamp_index` (`order_id`,`timestamp`),
  CONSTRAINT `email_delivery_logs_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_inbox`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_inbox` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `account_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `message_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thread_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `from_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `from_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subject` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `body_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `body_html` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `received_at` timestamp NOT NULL,
  `is_read` tinyint(1) NOT NULL DEFAULT '0',
  `is_replied` tinyint(1) NOT NULL DEFAULT '0',
  `linked_order_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `linked_ticket_id` bigint unsigned DEFAULT NULL,
  `assigned_to_admin_id` bigint unsigned DEFAULT NULL,
  `priority` enum('low','normal','high','urgent') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'normal',
  `status` enum('new','open','pending','resolved','closed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'new',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_inbox_message_id_unique` (`message_id`),
  KEY `email_inbox_account_email_received_at_index` (`account_email`,`received_at`),
  KEY `email_inbox_thread_id_index` (`thread_id`),
  KEY `email_inbox_status_priority_index` (`status`,`priority`),
  KEY `email_inbox_linked_order_id_index` (`linked_order_id`),
  KEY `email_inbox_assigned_to_admin_id_foreign` (`assigned_to_admin_id`),
  CONSTRAINT `email_inbox_assigned_to_admin_id_foreign` FOREIGN KEY (`assigned_to_admin_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `message_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `template_id` bigint unsigned DEFAULT NULL,
  `email_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'order, ticket, receipt, notification, etc.',
  `recipient_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `recipient_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `from_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `body_html` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `body_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `send_rate_hour` int NOT NULL DEFAULT '0',
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `bounce_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bounce_reason` text COLLATE utf8mb4_unicode_ci,
  `bounced_at` timestamp NULL DEFAULT NULL,
  `spam_report` tinyint(1) NOT NULL DEFAULT '0',
  `spam_reported_at` timestamp NULL DEFAULT NULL,
  `delivered_at` timestamp NULL DEFAULT NULL,
  `opened_at` timestamp NULL DEFAULT NULL,
  `clicked_at` timestamp NULL DEFAULT NULL,
  `clicked_link` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `spam_score` decimal(3,2) DEFAULT NULL,
  `delivery_time_ms` int DEFAULT NULL,
  `sent_at` timestamp NULL DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `tracking_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `smtp_message_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sent_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_logs_message_id_unique` (`message_id`),
  KEY `email_logs_recipient_email_status_index` (`recipient_email`,`status`),
  KEY `email_logs_template_id_sent_at_index` (`template_id`,`sent_at`),
  KEY `email_logs_status_created_at_index` (`status`,`created_at`),
  KEY `idx_sent_at_account` (`sent_at`,`from_email`),
  KEY `idx_status_type` (`status`,`email_type`),
  KEY `idx_email_logs_tracking_id` (`tracking_id`),
  CONSTRAINT `email_logs_template_id_foreign` FOREIGN KEY (`template_id`) REFERENCES `email_templates` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_rate_tracking`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_rate_tracking` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `account_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `hour_timestamp` timestamp NOT NULL COMMENT 'Rounded to hour for rate tracking',
  `emails_sent` int NOT NULL DEFAULT '0',
  `emails_bounced` int NOT NULL DEFAULT '0',
  `emails_spam_reported` int NOT NULL DEFAULT '0',
  `avg_delivery_time_ms` int NOT NULL DEFAULT '0',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_hour` (`account_email`,`hour_timestamp`),
  KEY `email_rate_tracking_account_email_hour_timestamp_index` (`account_email`,`hour_timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_reputation`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_reputation` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `account_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `emails_sent` int NOT NULL DEFAULT '0',
  `emails_delivered` int NOT NULL DEFAULT '0',
  `emails_bounced` int NOT NULL DEFAULT '0',
  `emails_failed` int NOT NULL DEFAULT '0',
  `hard_bounces` int NOT NULL DEFAULT '0',
  `soft_bounces` int NOT NULL DEFAULT '0',
  `spam_reports` int NOT NULL DEFAULT '0',
  `unsubscribes` int NOT NULL DEFAULT '0',
  `bounce_rate` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Percentage',
  `spam_rate` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Percentage',
  `delivery_rate` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Percentage',
  `health_score` decimal(5,2) NOT NULL DEFAULT '100.00' COMMENT '0-100 score',
  `status` enum('good','warning','critical') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'good',
  `alert_sent` tinyint(1) NOT NULL DEFAULT '0',
  `alert_sent_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_reputation_account_email_date_unique` (`account_email`,`date`),
  KEY `email_reputation_date_status_index` (`date`,`status`),
  KEY `email_reputation_account_email_date_status_index` (`account_email`,`date`,`status`),
  KEY `email_reputation_account_email_index` (`account_email`),
  KEY `email_reputation_date_index` (`date`),
  CONSTRAINT `email_reputation_account_email_foreign` FOREIGN KEY (`account_email`) REFERENCES `email_accounts` (`email`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_template_versions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_template_versions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `email_template_id` bigint unsigned NOT NULL,
  `version` int NOT NULL,
  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `html_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `text_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `variables` json DEFAULT NULL,
  `attachments` json DEFAULT NULL,
  `settings` json DEFAULT NULL,
  `changed_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `change_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_template_versions_email_template_id_version_unique` (`email_template_id`,`version`),
  KEY `email_template_versions_version_index` (`version`),
  CONSTRAINT `email_template_versions_email_template_id_foreign` FOREIGN KEY (`email_template_id`) REFERENCES `email_templates` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'system',
  `sender_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `sender_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `body_html` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `body_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `placeholders` json DEFAULT NULL,
  `attachments` json DEFAULT NULL,
  `version` int NOT NULL DEFAULT '1',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_system` tinyint(1) NOT NULL DEFAULT '0',
  `include_event_reminder` tinyint(1) NOT NULL DEFAULT '1',
  `include_venue_directions` tinyint(1) NOT NULL DEFAULT '1',
  `include_support_contact` tinyint(1) NOT NULL DEFAULT '1',
  `attach_pdf_ticket` tinyint(1) NOT NULL DEFAULT '1',
  `times_used` int NOT NULL DEFAULT '0',
  `last_used_at` timestamp NULL DEFAULT NULL,
  `created_by` int DEFAULT NULL,
  `updated_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_templates_slug_unique` (`slug`),
  KEY `email_templates_type_is_active_index` (`type`,`is_active`),
  KEY `email_templates_slug_index` (`slug`),
  KEY `email_templates_slug_is_active_index` (`slug`,`is_active`),
  KEY `email_templates_type_index` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `eod_reports`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `eod_reports` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `report_date` date NOT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'GBP',
  `expected_cash` decimal(12,2) NOT NULL DEFAULT '0.00',
  `expected_card` decimal(12,2) NOT NULL DEFAULT '0.00',
  `expected_total` decimal(12,2) NOT NULL DEFAULT '0.00',
  `actual_cash` decimal(12,2) NOT NULL DEFAULT '0.00',
  `actual_card` decimal(12,2) NOT NULL DEFAULT '0.00',
  `actual_total` decimal(12,2) NOT NULL DEFAULT '0.00',
  `cash_variance` decimal(12,2) NOT NULL DEFAULT '0.00',
  `card_variance` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total_variance` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total_variance_percent` decimal(8,4) NOT NULL DEFAULT '0.0000',
  `status` enum('pending','approved','flagged') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `staff_id` bigint unsigned NOT NULL,
  `manager_id` bigint unsigned DEFAULT NULL,
  `signed_off_at` timestamp NULL DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `manager_comments` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `investigation_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `audit_reference` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `eod_reports_audit_reference_unique` (`audit_reference`),
  UNIQUE KEY `eod_reports_date_event_unique` (`report_date`,`event_id`),
  KEY `eod_reports_report_date_event_id_index` (`report_date`,`event_id`),
  KEY `eod_reports_status_report_date_index` (`status`,`report_date`),
  KEY `eod_reports_staff_id_index` (`staff_id`),
  KEY `eod_reports_manager_id_index` (`manager_id`),
  KEY `eod_reports_event_id_foreign` (`event_id`),
  CONSTRAINT `eod_reports_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL,
  CONSTRAINT `eod_reports_manager_id_foreign` FOREIGN KEY (`manager_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  CONSTRAINT `eod_reports_staff_id_foreign` FOREIGN KEY (`staff_id`) REFERENCES `admins` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `event_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `icon` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color` varchar(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `event_categories_name_unique` (`name`),
  UNIQUE KEY `event_categories_slug_unique` (`slug`),
  KEY `event_categories_slug_index` (`slug`),
  KEY `event_categories_is_active_index` (`is_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `event_images`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_images` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `imageable_id` bigint unsigned NOT NULL,
  `imageable_type` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'gallery',
  `filename` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `storage_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thumbnail_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `large_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `title` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `caption` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `alt_text` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `width` int DEFAULT NULL,
  `height` int DEFAULT NULL,
  `file_size` int DEFAULT NULL,
  `mime_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_featured` tinyint(1) NOT NULL DEFAULT '0',
  `display_order` int NOT NULL DEFAULT '0',
  `legacy_image_id` int unsigned DEFAULT NULL,
  `download_status` enum('pending','downloaded','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'downloaded',
  `download_error` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `migrated_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_imageable` (`imageable_type`,`imageable_id`),
  KEY `event_images_legacy_image_id_index` (`legacy_image_id`),
  KEY `event_images_is_featured_index` (`is_featured`),
  KEY `event_images_download_status_index` (`download_status`),
  KEY `event_images_role_index` (`role`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `event_photos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_photos` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `file_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` bigint unsigned NOT NULL,
  `is_featured` tinyint NOT NULL DEFAULT '0',
  `status` tinyint NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `event_photos_event_id_foreign` (`event_id`),
  CONSTRAINT `event_photos_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `event_venues`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_venues` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `venue_template_id` bigint unsigned NOT NULL,
  `pricing_overrides` json DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_event_venue_template` (`event_id`,`venue_template_id`),
  KEY `idx_event_venues_event_id` (`event_id`),
  KEY `idx_event_venues_venue_template_id` (`venue_template_id`),
  KEY `idx_event_venues_event_active` (`event_id`,`is_active`),
  CONSTRAINT `fk_event_venues_event_id` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_event_venues_venue_template_id` FOREIGN KEY (`venue_template_id`) REFERENCES `venue_templates` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `event_wise_seat_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_wise_seat_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint NOT NULL,
  `seats` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `ticket_category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `zone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `event_wise_seat_categories_seats_event_id_index` (`seats`,`event_id`),
  KEY `event_wise_seat_categories_event_id_index` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `events` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `legacy_event_id` int unsigned DEFAULT NULL COMMENT 'Original event ID from legacy globalgala system',
  `theme_id` bigint unsigned DEFAULT NULL,
  `venue_id` bigint unsigned DEFAULT NULL,
  `category_id` bigint unsigned DEFAULT NULL,
  `club_id` bigint unsigned DEFAULT NULL,
  `organizer_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `organizer_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `organizer_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `sub_title` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category` enum('concert','conference','convention','exhibition','festival','party','performance','other') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Event category for Revolut industry_data (improves acceptance rates)',
  `market` enum('primary','secondary') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'primary' COMMENT 'Ticket distribution type: primary (organizer) or secondary (reseller)',
  `event_image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `page_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `start_date` date NOT NULL,
  `event_year` int unsigned DEFAULT NULL COMMENT 'Year for archival grouping (especially for legacy events with missing dates)',
  `end_date` date DEFAULT NULL,
  `supplier_payment_date` datetime DEFAULT NULL COMMENT 'Date when funds released to supplier (default: event_date + 7 days)',
  `start_time` time DEFAULT NULL,
  `doors_open_time` time DEFAULT NULL,
  `timezone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'UTC',
  `voting_end_time` datetime DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `map_banner_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `booking_banner_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `inquiry_poll` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `event_email_thankyou_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `event_support_thankyou_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `meta_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_featured` tinyint(1) NOT NULL DEFAULT '0',
  `meta_title` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_keyword` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_published` tinyint(1) NOT NULL DEFAULT '0',
  `is_legacy` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indicates if event is from legacy archive (not bookable)',
  `display_order` int unsigned NOT NULL DEFAULT '0' COMMENT 'Manual sorting order for event listings',
  `is_test_mode` tinyint(1) NOT NULL DEFAULT '0',
  `publish_website` tinyint(1) NOT NULL DEFAULT '0',
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '£',
  `booking_mode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'seat',
  `max_no_of_tickets` int DEFAULT NULL,
  `ticket_template_id` bigint unsigned DEFAULT NULL,
  `bracelet_template_id` bigint unsigned DEFAULT NULL,
  `venue_fork_data` json DEFAULT NULL COMMENT 'Fork metadata (source_template_id, version, forked_at, fork_type, changes_since_fork, last_sync_at)',
  `label_template_id` bigint unsigned DEFAULT NULL,
  `no_of_raffle_ticket` int DEFAULT NULL,
  `raffle_ticket_price` double(8,2) DEFAULT NULL,
  `video` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `main_page_banner` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `centered_banner` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `baner_wide` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `banner_tablet` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `banner_phone` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `destaque_home` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `imagem_poster` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `buttom_banner_frame` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `legacy_metadata` json DEFAULT NULL COMMENT 'JSON storage for legacy system data (original status, notes, etc.)',
  `enable_booking_fee` tinyint(1) NOT NULL DEFAULT '0',
  `enable_vat` tinyint(1) NOT NULL DEFAULT '0',
  `booking_fee_rate` decimal(5,4) DEFAULT NULL,
  `booking_fee_min` decimal(8,2) DEFAULT NULL,
  `booking_fee_max` decimal(8,2) DEFAULT NULL,
  `vat_rate` decimal(5,4) DEFAULT NULL,
  `ticket_code_type` enum('qr','barcode','both') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'qr' COMMENT 'Primary code type for tickets (qr, barcode, or both)',
  `email_code_type` enum('qr','barcode') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'qr' COMMENT 'Code type to display in emails (qr or barcode only)',
  `wristband_code_type` enum('qr','barcode') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'barcode' COMMENT 'Code type for wristband printing (usually barcode)',
  `pdf_code_type` enum('qr','barcode','both') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'qr' COMMENT 'Code type for PDF tickets',
  `enable_wristband_printing` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Enable wristband printing for this event',
  `wristband_printer_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Zebra printer identifier for this event',
  `wristband_printing_enabled_at` timestamp NULL DEFAULT NULL COMMENT 'Timestamp when wristband printing was enabled',
  `scanner_config` json DEFAULT NULL COMMENT 'Scanner configuration (allowed code types, duplicate window, etc.)',
  `is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT 'allow only 0 / 1 for true and false',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `sell_start_date` date DEFAULT NULL,
  `sell_start_time` time DEFAULT NULL,
  `sell_end_date` date DEFAULT NULL,
  `sell_end_time` time DEFAULT NULL,
  `publish_start_date` date DEFAULT NULL,
  `publish_start_time` time DEFAULT NULL,
  `publish_end_date` date DEFAULT NULL,
  `publish_end_time` time DEFAULT NULL,
  `include_booking_fee` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Whether booking fee (2.5%) is included for public bookings',
  `include_tax` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Whether tax (21% VAT) is included for public bookings',
  `video_url` varchar(2083) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Bunny CDN video embed URL',
  `video_thumbnail_url` varchar(2083) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Bunny CDN video thumbnail/poster URL',
  PRIMARY KEY (`id`),
  UNIQUE KEY `events_slug_unique` (`slug`),
  KEY `events_slug_index` (`slug`),
  KEY `events_venue_id_foreign` (`venue_id`),
  KEY `events_page_name_index` (`page_name`),
  KEY `events_is_published_index` (`is_published`),
  KEY `events_is_featured_index` (`is_featured`),
  KEY `events_theme_id_foreign` (`theme_id`),
  KEY `events_category_index` (`category`),
  KEY `events_market_index` (`market`),
  KEY `idx_events_public_filtering` (`is_deleted`,`is_published`,`is_test_mode`,`start_date`),
  KEY `idx_events_featured_published` (`is_deleted`,`is_featured`,`is_published`),
  KEY `idx_events_wristband_printing` (`enable_wristband_printing`),
  KEY `events_legacy_event_id_index` (`legacy_event_id`),
  KEY `events_is_legacy_index` (`is_legacy`),
  KEY `events_event_year_index` (`event_year`),
  KEY `events_display_order_index` (`display_order`),
  CONSTRAINT `events_theme_id_foreign` FOREIGN KEY (`theme_id`) REFERENCES `venue_themes` (`id`) ON DELETE SET NULL,
  CONSTRAINT `events_venue_id_foreign` FOREIGN KEY (`venue_id`) REFERENCES `venues` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `failed_invitation_attempts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `failed_invitation_attempts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `invitation_id` bigint unsigned NOT NULL,
  `campaign_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `failure_type` enum('invalid_email','server_error','timeout','hard_bounce','soft_bounce','unknown') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Categorized failure reason',
  `failure_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Human-readable failure description',
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `retry_count` int NOT NULL DEFAULT '0' COMMENT 'Number of retry attempts',
  `can_retry` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Whether retry is allowed',
  `last_error` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Last SMTP or exception error',
  `metadata` json DEFAULT NULL COMMENT 'Additional failure context',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_failed_invitation_id` (`invitation_id`),
  KEY `idx_failed_campaign_name` (`campaign_name`),
  KEY `idx_failure_type` (`failure_type`),
  KEY `idx_can_retry` (`can_retry`),
  KEY `idx_failed_at` (`failed_at`),
  KEY `idx_failed_campaign_type` (`campaign_name`,`failure_type`),
  CONSTRAINT `failed_invitation_attempts_invitation_id_foreign` FOREIGN KEY (`invitation_id`) REFERENCES `account_setup_invitations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `failed_jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `failed_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `faqs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `faqs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `question` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `answer` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `priority` int NOT NULL DEFAULT '0',
  `status` tinyint NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `features`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `features` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `feature` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `active_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `features_feature_unique` (`feature`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `fee_waiver_audit_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fee_waiver_audit_log` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned DEFAULT NULL,
  `reservation_id` bigint unsigned DEFAULT NULL,
  `admin_user_id` bigint unsigned DEFAULT NULL,
  `waiver_type` enum('booking_fee','tax','both') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Reason for waiver: VIP, promotion, tax-exempt, comp ticket, etc.',
  `waived_amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Total amount of fees/tax waived in euros',
  `customer_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `metadata` json DEFAULT NULL COMMENT 'Additional context: seats, pricing breakdown, etc.',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fee_waiver_audit_log_order_id_foreign` (`order_id`),
  KEY `fee_waiver_audit_log_reservation_id_foreign` (`reservation_id`),
  KEY `fee_waiver_audit_log_created_at_index` (`created_at`),
  KEY `fee_waiver_audit_log_admin_user_id_created_at_index` (`admin_user_id`,`created_at`),
  KEY `fee_waiver_audit_log_event_id_created_at_index` (`event_id`,`created_at`),
  KEY `fee_waiver_audit_log_waiver_type_index` (`waiver_type`),
  KEY `fee_waiver_audit_log_customer_email_index` (`customer_email`),
  CONSTRAINT `fee_waiver_audit_log_admin_user_id_foreign` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fee_waiver_audit_log_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fee_waiver_audit_log_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fee_waiver_audit_log_reservation_id_foreign` FOREIGN KEY (`reservation_id`) REFERENCES `seat_reservations` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `fire_marshal_access_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fire_marshal_access_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `token_id` bigint unsigned NOT NULL COMMENT 'Fire marshal token ID',
  `event_id` bigint unsigned DEFAULT NULL COMMENT 'Event accessed',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'IP address of access',
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Browser user agent',
  `accessed_at` timestamp NOT NULL COMMENT 'When report was accessed',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fire_marshal_access_logs_token_id_index` (`token_id`),
  KEY `fire_marshal_access_logs_event_id_index` (`event_id`),
  KEY `fire_marshal_access_logs_accessed_at_index` (`accessed_at`),
  KEY `fire_marshal_access_logs_ip_address_index` (`ip_address`),
  CONSTRAINT `fire_marshal_access_logs_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fire_marshal_access_logs_token_id_foreign` FOREIGN KEY (`token_id`) REFERENCES `fire_marshal_tokens` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Audit log of fire marshal report access';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `fire_marshal_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fire_marshal_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'SHA256 hash of access token',
  `event_id` bigint unsigned DEFAULT NULL COMMENT 'Event ID (null = all events)',
  `authorized_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Fire marshal name',
  `authorized_agency` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Fire safety agency/department',
  `authorized_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Contact email',
  `authorized_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Contact phone',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Token active status',
  `expires_at` timestamp NULL DEFAULT NULL COMMENT 'Token expiration (e.g., 24 hours)',
  `max_uses` int DEFAULT NULL COMMENT 'Maximum number of uses (null = unlimited)',
  `use_count` int NOT NULL DEFAULT '0' COMMENT 'Number of times token has been used',
  `created_by` bigint unsigned DEFAULT NULL COMMENT 'Admin who issued token',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Admin notes about access grant',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fire_marshal_tokens_token_unique` (`token`),
  KEY `fire_marshal_tokens_token_index` (`token`),
  KEY `fire_marshal_tokens_event_id_index` (`event_id`),
  KEY `fire_marshal_tokens_is_active_expires_at_index` (`is_active`,`expires_at`),
  KEY `fire_marshal_tokens_authorized_agency_index` (`authorized_agency`),
  KEY `fire_marshal_tokens_created_by_foreign` (`created_by`),
  CONSTRAINT `fire_marshal_tokens_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fire_marshal_tokens_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Fire marshal report access tokens';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `fundraising_profiles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fundraising_profiles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `name` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `profile_photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'avatar.png',
  `cover_photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'sample1.jpg',
  `story` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `goal` int NOT NULL DEFAULT '0',
  `amount_raised` int NOT NULL DEFAULT '0',
  `type` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U' COMMENT 'U-User, T-Team',
  `status` tinyint NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fundraising_profiles_name_unique` (`name`),
  KEY `fundraising_profiles_user_id_foreign` (`user_id`),
  CONSTRAINT `fundraising_profiles_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `fundraising_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fundraising_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `profile_id` bigint unsigned NOT 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,
  `message` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` int NOT NULL,
  `reference` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Stripe ID',
  `anonymous` tinyint NOT NULL,
  `status` tinyint NOT NULL DEFAULT '0' COMMENT '0-Created,1-Paid',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fundraising_transactions_profile_id_foreign` (`profile_id`),
  CONSTRAINT `fundraising_transactions_profile_id_foreign` FOREIGN KEY (`profile_id`) REFERENCES `fundraising_profiles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `gala_state_transitions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `gala_state_transitions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `gala_id` bigint unsigned NOT NULL,
  `from_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `to_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_automatic` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'true = time-based auto transition, false = manual',
  `was_successful` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'false if transition failed/was rejected',
  `transitioned_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `latency_ms` int unsigned DEFAULT NULL COMMENT 'Time to complete transition in milliseconds',
  `time_in_previous_state_seconds` int unsigned DEFAULT NULL COMMENT 'Time spent in from_status before this transition',
  `triggered_by_admin_id` bigint unsigned DEFAULT NULL COMMENT 'Admin ID if manual/forced transition',
  `metadata` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'JSON metadata for debugging',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_gst_gala_id` (`gala_id`),
  KEY `idx_gst_from_status` (`from_status`),
  KEY `idx_gst_to_status` (`to_status`),
  KEY `idx_gst_transitioned_at` (`transitioned_at`),
  KEY `idx_gst_gala_timeline` (`gala_id`,`transitioned_at`),
  KEY `idx_gst_type_success` (`is_automatic`,`was_successful`),
  KEY `gala_state_transitions_triggered_by_admin_id_foreign` (`triggered_by_admin_id`),
  CONSTRAINT `gala_state_transitions_gala_id_foreign` FOREIGN KEY (`gala_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `gala_state_transitions_triggered_by_admin_id_foreign` FOREIGN KEY (`triggered_by_admin_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `galleries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `galleries` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `images` json NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `display_order` int NOT NULL DEFAULT '0',
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `galleries_is_active_display_order_index` (`is_active`,`display_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `gdpr_audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `gdpr_audit_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Type of GDPR event (export, anonymize, delete, access)',
  `entity_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Type of entity accessed (order, payment_transaction, user)',
  `entity_id` bigint unsigned DEFAULT NULL COMMENT 'ID of the entity accessed',
  `user_id` bigint unsigned DEFAULT NULL COMMENT 'User who initiated the action',
  `user_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Type of user (customer, admin, system)',
  `user_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Email of user who initiated action',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'IP address of requester',
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Browser user agent',
  `request_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'HTTP method (GET, POST, etc.)',
  `request_url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'URL that was accessed',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Human-readable description of action',
  `metadata` json DEFAULT NULL COMMENT 'Additional context data',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'success' COMMENT 'Status of the action (success, failed, pending)',
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Error message if action failed',
  `data_retention_until` timestamp NULL DEFAULT NULL COMMENT 'When this audit log should be deleted',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `gdpr_audit_logs_event_type_index` (`event_type`),
  KEY `gdpr_audit_logs_entity_type_index` (`entity_type`),
  KEY `gdpr_audit_logs_entity_type_entity_id_index` (`entity_type`,`entity_id`),
  KEY `gdpr_audit_logs_user_id_index` (`user_id`),
  KEY `gdpr_audit_logs_created_at_index` (`created_at`),
  KEY `gdpr_audit_logs_data_retention_until_index` (`data_retention_until`),
  KEY `gdpr_audit_logs_event_type_created_at_index` (`event_type`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `homepage_sections`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `homepage_sections` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `section_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `content` json NOT NULL,
  `display_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_section_active_order` (`section_type`,`is_active`,`display_order`),
  KEY `homepage_sections_section_type_index` (`section_type`),
  KEY `homepage_sections_display_order_index` (`display_order`),
  KEY `homepage_sections_is_active_index` (`is_active`),
  KEY `idx_section_type_active_order` (`section_type`,`is_active`,`display_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `queue` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempts` tinyint unsigned NOT NULL,
  `reserved_at` int unsigned DEFAULT NULL,
  `available_at` int unsigned NOT NULL,
  `created_at` int unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `jobs_queue_index` (`queue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `manager_overrides`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `manager_overrides` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` bigint unsigned NOT NULL,
  `manager_id` bigint unsigned NOT NULL,
  `supervisor_id` bigint unsigned DEFAULT NULL,
  `override_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `override_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `pin_verification` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci 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,
  `validation_failure_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `validation_failure_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `validation_context` json DEFAULT NULL,
  `supervisor_alerted` tinyint(1) NOT NULL DEFAULT '0',
  `supervisor_alerted_at` timestamp NULL DEFAULT NULL,
  `alert_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `device_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `scanner_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `overridden_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `manager_overrides_manager_id_created_at_index` (`manager_id`,`created_at`),
  KEY `manager_overrides_ticket_id_created_at_index` (`ticket_id`,`created_at`),
  KEY `manager_overrides_overridden_at_index` (`overridden_at`),
  KEY `manager_overrides_ticket_id_index` (`ticket_id`),
  KEY `manager_overrides_manager_id_index` (`manager_id`),
  KEY `manager_overrides_supervisor_id_index` (`supervisor_id`),
  KEY `manager_overrides_override_reason_index` (`override_reason`),
  CONSTRAINT `manager_overrides_manager_id_foreign` FOREIGN KEY (`manager_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `manager_overrides_supervisor_id_foreign` FOREIGN KEY (`supervisor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `manager_overrides_ticket_id_foreign` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mbs_activity_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mbs_activity_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `staff_user_id` bigint unsigned NOT NULL,
  `staff_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `staff_user_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `event_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_id` bigint unsigned DEFAULT NULL,
  `order_reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `seat_id` bigint unsigned DEFAULT NULL,
  `seat_identifier` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `action_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `action_category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `action_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `request_method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `request_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `old_values` json DEFAULT NULL,
  `new_values` json DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `success` tinyint(1) NOT NULL DEFAULT '1',
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `correlation_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `severity` enum('low','medium','high','critical') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'medium',
  `requires_review` tinyint(1) NOT NULL DEFAULT '0',
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `reviewed_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `mbs_activity_logs_staff_user_id_index` (`staff_user_id`),
  KEY `mbs_activity_logs_event_id_index` (`event_id`),
  KEY `mbs_activity_logs_order_id_index` (`order_id`),
  KEY `mbs_activity_logs_created_at_index` (`created_at`),
  KEY `mbs_activity_logs_action_type_created_at_index` (`action_type`,`created_at`),
  KEY `mbs_activity_logs_staff_user_id_created_at_index` (`staff_user_id`,`created_at`),
  KEY `mbs_activity_logs_event_id_created_at_index` (`event_id`,`created_at`),
  KEY `mbs_activity_logs_success_created_at_index` (`success`,`created_at`),
  KEY `mbs_activity_logs_requires_review_index` (`requires_review`),
  KEY `mbs_activity_logs_action_type_index` (`action_type`),
  KEY `mbs_activity_logs_action_category_index` (`action_category`),
  KEY `mbs_activity_logs_correlation_id_index` (`correlation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `migrations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `newsletter_campaign_recipients`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `newsletter_campaign_recipients` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `campaign_id` bigint unsigned NOT NULL,
  `contact_id` bigint unsigned NOT NULL,
  `status` enum('pending','sent','failed','bounced') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `sent_at` timestamp NULL DEFAULT NULL,
  `opened_at` timestamp NULL DEFAULT NULL,
  `clicked_at` timestamp NULL DEFAULT NULL,
  `open_count` int NOT NULL DEFAULT '0',
  `click_count` int NOT NULL DEFAULT '0',
  `error_message` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `newsletter_campaign_recipients_campaign_id_contact_id_unique` (`campaign_id`,`contact_id`),
  KEY `newsletter_campaign_recipients_campaign_id_status_index` (`campaign_id`,`status`),
  KEY `newsletter_campaign_recipients_contact_id_campaign_id_index` (`contact_id`,`campaign_id`),
  CONSTRAINT `newsletter_campaign_recipients_campaign_id_foreign` FOREIGN KEY (`campaign_id`) REFERENCES `newsletter_campaigns` (`id`) ON DELETE CASCADE,
  CONSTRAINT `newsletter_campaign_recipients_contact_id_foreign` FOREIGN KEY (`contact_id`) REFERENCES `newsletter_contacts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `newsletter_campaigns`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `newsletter_campaigns` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `template_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Template identifier (e.g., welcome, event-announcement)',
  `field_values` json DEFAULT NULL COMMENT 'User-provided field values for the template',
  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `preview_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `html_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `text_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `template_components` json DEFAULT NULL,
  `email_template_id` bigint unsigned DEFAULT NULL,
  `template_data` json DEFAULT NULL,
  `audience_type` enum('all','active','new','custom','import_batch') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'all',
  `audience_filters` json DEFAULT NULL,
  `target_import_batch_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('draft','scheduled','sending','sent','failed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `scheduled_at` timestamp NULL DEFAULT NULL,
  `started_sending_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `from_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Global Gala',
  `from_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'info@showprima.com',
  `reply_to_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_recipients` int NOT NULL DEFAULT '0',
  `sent_count` int NOT NULL DEFAULT '0',
  `failed_count` int NOT NULL DEFAULT '0',
  `opened_count` int NOT NULL DEFAULT '0',
  `clicked_count` int NOT NULL DEFAULT '0',
  `unsubscribed_count` int NOT NULL DEFAULT '0',
  `bounced_count` int NOT NULL DEFAULT '0',
  `complained_count` int NOT NULL DEFAULT '0',
  `created_by` bigint unsigned DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `newsletter_campaigns_email_template_id_foreign` (`email_template_id`),
  KEY `newsletter_campaigns_status_index` (`status`),
  KEY `newsletter_campaigns_scheduled_at_index` (`scheduled_at`),
  KEY `newsletter_campaigns_created_by_index` (`created_by`),
  KEY `newsletter_campaigns_status_scheduled_at_index` (`status`,`scheduled_at`),
  CONSTRAINT `newsletter_campaigns_email_template_id_foreign` FOREIGN KEY (`email_template_id`) REFERENCES `email_templates` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `newsletter_contacts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `newsletter_contacts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `first_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `full_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('subscribed','unsubscribed','bounced','complained') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'subscribed',
  `subscription_token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `consent_status` enum('explicit','legacy','imported') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'imported',
  `subscribed_at` timestamp NULL DEFAULT NULL,
  `unsubscribed_at` timestamp NULL DEFAULT NULL,
  `unsubscribe_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `import_batch_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `emails_sent` int NOT NULL DEFAULT '0',
  `emails_opened` int NOT NULL DEFAULT '0',
  `emails_clicked` int NOT NULL DEFAULT '0',
  `bounce_count` int NOT NULL DEFAULT '0',
  `last_sent_at` timestamp NULL DEFAULT NULL,
  `last_opened_at` timestamp NULL DEFAULT NULL,
  `consent_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `signup_ip` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `signup_user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `newsletter_contacts_email_unique` (`email`),
  UNIQUE KEY `newsletter_contacts_subscription_token_unique` (`subscription_token`),
  KEY `newsletter_contacts_status_index` (`status`),
  KEY `newsletter_contacts_import_batch_id_index` (`import_batch_id`),
  KEY `newsletter_contacts_status_consent_status_index` (`status`,`consent_status`),
  KEY `newsletter_contacts_created_at_index` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `newsletter_subscription_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `newsletter_subscription_history` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contact_id` bigint unsigned NOT NULL,
  `action` enum('subscribed','unsubscribed','resubscribed','bounced','complained') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `created_at` timestamp NOT NULL,
  PRIMARY KEY (`id`),
  KEY `newsletter_subscription_history_contact_id_action_index` (`contact_id`,`action`),
  KEY `newsletter_subscription_history_created_at_index` (`created_at`),
  KEY `newsletter_subscription_history_action_index` (`action`),
  CONSTRAINT `newsletter_subscription_history_contact_id_foreign` FOREIGN KEY (`contact_id`) REFERENCES `newsletter_contacts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `newsletter_subscriptions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `newsletter_subscriptions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contact_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `subscription_type` enum('newsletter','event_updates','promotional','transactional') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'newsletter',
  `status` enum('active','paused','unsubscribed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `subscribed_at` timestamp NOT NULL,
  `unsubscribed_at` timestamp NULL DEFAULT NULL,
  `source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `newsletter_subscriptions_contact_id_subscription_type_unique` (`contact_id`,`subscription_type`),
  KEY `newsletter_subscriptions_contact_id_subscription_type_index` (`contact_id`,`subscription_type`),
  KEY `newsletter_subscriptions_user_id_status_index` (`user_id`,`status`),
  CONSTRAINT `newsletter_subscriptions_contact_id_foreign` FOREIGN KEY (`contact_id`) REFERENCES `newsletter_contacts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `newsletter_subscriptions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `notification_preferences`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `notification_preferences` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `notification_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `channels` json DEFAULT NULL,
  `opt_out` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `notif_prefs_user_type_unique` (`user_id`,`notification_type`),
  KEY `notif_prefs_type_index` (`notification_type`),
  CONSTRAINT `notification_preferences_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_audit_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_audit_log` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `admin_user_id` bigint unsigned NOT NULL,
  `action` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `old_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `new_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_audit_log_order_id_created_at_index` (`order_id`,`created_at`),
  KEY `order_audit_log_admin_user_id_created_at_index` (`admin_user_id`,`created_at`),
  KEY `order_audit_log_action_index` (`action`),
  KEY `order_audit_log_order_id_index` (`order_id`),
  CONSTRAINT `order_audit_log_admin_user_id_foreign` FOREIGN KEY (`admin_user_id`) REFERENCES `admins` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint NOT NULL,
  `event_id` bigint NOT NULL,
  `user_id` bigint DEFAULT NULL,
  `amount` decimal(10,2) NOT NULL,
  `seat` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `zone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ticket_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `sub_cat` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `quantity` int NOT NULL DEFAULT '1',
  `status` tinyint NOT NULL DEFAULT '1',
  `pdf_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pdf_generation_status` enum('pending','processing','ready','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `pdf_generation_error` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `pdf_generated_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_items_event_id_seat_status_index` (`event_id`,`seat`,`status`),
  KEY `order_items_order_id_index` (`order_id`),
  KEY `order_items_user_id_index` (`user_id`),
  KEY `order_items_pdf_generation_status_index` (`pdf_generation_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_line_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_line_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL COMMENT 'Foreign key to orders table',
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Session ID for order tracking',
  `seat_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Seat ID if this is a ticket line item',
  `item_type` enum('ticket','booking_fee','service_fee','tax','discount') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Type of line item',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Human-readable description',
  `unit_price` decimal(10,2) NOT NULL COMMENT 'Price per unit',
  `quantity` int NOT NULL DEFAULT '1' COMMENT 'Quantity of items',
  `line_total` decimal(10,2) NOT NULL COMMENT 'Total for this line (unit_price * quantity)',
  `original_price_at_booking` decimal(10,2) DEFAULT NULL COMMENT 'Price at time of booking for accurate refund calculations',
  `metadata` json DEFAULT NULL COMMENT 'Additional metadata (seat_number, rates, etc.)',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_line_items_order_id_index` (`order_id`),
  KEY `order_line_items_session_id_index` (`session_id`),
  KEY `order_line_items_seat_id_index` (`seat_id`),
  KEY `order_line_items_item_type_index` (`item_type`),
  KEY `order_line_items_order_id_item_type_index` (`order_id`,`item_type`),
  CONSTRAINT `order_line_items_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_modifications`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_modifications` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned DEFAULT NULL,
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modification_type` enum('add_seats','remove_seats','apply_discount','apply_credit','adjust_total','reassign_seat') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('pending','approved','rejected','applied') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `amount_change` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Positive for additions, negative for reductions',
  `old_total` decimal(10,2) DEFAULT NULL,
  `new_total` decimal(10,2) DEFAULT NULL,
  `modification_data` json DEFAULT NULL COMMENT 'Details of the modification (seats added/removed, discount info, etc.)',
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `requested_by` bigint unsigned DEFAULT NULL COMMENT 'Admin user who requested the modification',
  `approved_by` bigint unsigned DEFAULT NULL COMMENT 'Admin user who approved the modification',
  `rejected_by` bigint unsigned DEFAULT NULL COMMENT 'Admin user who rejected the modification',
  `approved_at` timestamp NULL DEFAULT NULL,
  `rejected_at` timestamp NULL DEFAULT NULL,
  `applied_at` timestamp NULL DEFAULT NULL,
  `rejection_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `idempotency_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `order_modifications_idempotency_key_unique` (`idempotency_key`),
  KEY `order_modifications_requested_by_foreign` (`requested_by`),
  KEY `order_modifications_approved_by_foreign` (`approved_by`),
  KEY `order_modifications_rejected_by_foreign` (`rejected_by`),
  KEY `order_modifications_modification_type_index` (`modification_type`),
  KEY `order_modifications_status_index` (`status`),
  KEY `order_modifications_order_id_status_index` (`order_id`,`status`),
  KEY `order_modifications_created_at_index` (`created_at`),
  KEY `order_modifications_session_id_index` (`session_id`),
  CONSTRAINT `order_modifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `order_modifications_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `order_modifications_rejected_by_foreign` FOREIGN KEY (`rejected_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `order_modifications_requested_by_foreign` FOREIGN KEY (`requested_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_notes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `admin_id` bigint unsigned NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_internal` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Internal staff notes vs customer-visible notes',
  `is_edited` tinyint(1) NOT NULL DEFAULT '0',
  `edited_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_notes_order_id_created_at_index` (`order_id`,`created_at`),
  KEY `order_notes_admin_id_index` (`admin_id`),
  CONSTRAINT `order_notes_admin_id_foreign` FOREIGN KEY (`admin_id`) REFERENCES `admins` (`id`) ON DELETE RESTRICT,
  CONSTRAINT `order_notes_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_refunds`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_refunds` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `refund_amount` decimal(10,2) NOT NULL,
  `refund_type` enum('full','partial') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'full',
  `refund_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `payment_gateway` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gateway_refund_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gateway_response` json DEFAULT NULL,
  `status` enum('pending','processing','completed','failed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `processed_by` bigint unsigned DEFAULT NULL,
  `processed_at` timestamp NULL DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_refunds_event_id_foreign` (`event_id`),
  KEY `order_refunds_processed_by_foreign` (`processed_by`),
  KEY `order_refunds_order_id_status_index` (`order_id`,`status`),
  KEY `order_refunds_gateway_refund_id_index` (`gateway_refund_id`),
  KEY `order_refunds_created_at_index` (`created_at`),
  CONSTRAINT `order_refunds_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL,
  CONSTRAINT `order_refunds_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `order_refunds_processed_by_foreign` FOREIGN KEY (`processed_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_status_audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_status_audit_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `old_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `new_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `changed_by_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'system',
  `changed_by_id` bigint unsigned DEFAULT NULL,
  `trigger_source` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `trigger_event_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `metadata` json DEFAULT NULL,
  `changed_at` timestamp NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_audit_order_id` (`order_id`),
  KEY `idx_audit_new_status` (`new_status`),
  KEY `idx_audit_changed_at` (`changed_at`),
  KEY `idx_audit_order_timeline` (`order_id`,`changed_at`),
  CONSTRAINT `order_status_audit_logs_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `orders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `payment_intent_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stripe_charge_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stripe_customer_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `created_by_admin_id` bigint unsigned DEFAULT NULL,
  `staff_id` bigint unsigned DEFAULT NULL COMMENT 'Scanner device/staff member who processed this POS transaction',
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_reference` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `admin_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `total_amount` decimal(10,2) NOT NULL,
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'GBP' COMMENT 'ISO 4217 currency code at time of order',
  `balance_due` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Remaining balance for deposits (0 for full payments)',
  `reserved_until` timestamp NULL DEFAULT NULL COMMENT 'Expiry timestamp for reserved orders (null for non-reserves)',
  `has_been_reseated` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if this order has been reseated at least once',
  `reseat_count` int unsigned NOT NULL DEFAULT '0' COMMENT 'Number of times this order has been reseated',
  `coupon_id` bigint unsigned DEFAULT NULL COMMENT 'Which coupon was used for this order',
  `discount_applied` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Total discount amount applied',
  `original_total` decimal(10,2) DEFAULT NULL COMMENT 'Order total before discount (for analytics, refunds)',
  `idempotency_key` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `payment_status` enum('paid','deposit_paid','reserved','pending','refunded') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'paid' COMMENT 'Payment status for order lifecycle tracking',
  `payment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_verified` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indicates if payment was verified by staff (especially for cash)',
  `payment_mode` enum('immediate','cash','invoice','comp','shadow_sold') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'immediate',
  `revolut_payment_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `revolut_order_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `revolut_status` enum('pending','processing','completed','failed','declined','cancelled','refunded') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `revolut_payment_completed_at` timestamp NULL DEFAULT NULL,
  `payment_reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `include_booking_fee` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Whether booking fee was included in this order',
  `include_tax` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Whether tax was included in this order',
  `tax_rate_snapshot` decimal(5,4) DEFAULT NULL COMMENT 'Tax rate at booking time. NULL = historical 0.21',
  `confirmed_by_admin_id` bigint unsigned DEFAULT NULL,
  `confirmed_at` timestamp NULL DEFAULT NULL,
  `confirmation_email_sent` tinyint(1) NOT NULL DEFAULT '0',
  `confirmation_email_sent_at` timestamp NULL DEFAULT NULL,
  `confirmation_email_opened_at` timestamp NULL DEFAULT NULL,
  `confirmation_email_tracking_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tickets_generated` tinyint(1) NOT NULL DEFAULT '0',
  `tickets_generated_at` timestamp NULL DEFAULT NULL,
  `tickets_pdf_path` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tickets_pdf_size_kb` int DEFAULT NULL,
  `wallet_pass_available` tinyint(1) NOT NULL DEFAULT '0',
  `wallet_pass_url` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `data_retention_until` timestamp NULL DEFAULT NULL COMMENT 'Date when this record should be anonymized/deleted per GDPR',
  `is_anonymized` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether personal data has been anonymized',
  `anonymized_at` timestamp NULL DEFAULT NULL COMMENT 'When the record was anonymized',
  `anonymized_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Reason for anonymization (e.g., retention_policy, user_request)',
  PRIMARY KEY (`id`),
  UNIQUE KEY `orders_idempotency_key_unique` (`idempotency_key`),
  KEY `orders_event_id_index` (`event_id`),
  KEY `orders_user_id_index` (`user_id`),
  KEY `orders_status_index` (`status`),
  KEY `orders_customer_email_index` (`customer_email`),
  KEY `orders_revolut_payment_id_index` (`revolut_payment_id`),
  KEY `orders_revolut_order_id_index` (`revolut_order_id`),
  KEY `idx_orders_created_at` (`created_at`),
  KEY `orders_payment_intent_id_index` (`payment_intent_id`),
  KEY `orders_stripe_charge_id_index` (`stripe_charge_id`),
  KEY `orders_payment_status_index` (`payment_status`),
  KEY `orders_stripe_customer_id_index` (`stripe_customer_id`),
  KEY `orders_data_retention_until_index` (`data_retention_until`),
  KEY `orders_is_anonymized_data_retention_until_index` (`is_anonymized`,`data_retention_until`),
  KEY `orders_created_by_admin_id_foreign` (`created_by_admin_id`),
  KEY `orders_payment_mode_index` (`payment_mode`),
  KEY `orders_confirmation_email_sent_index` (`confirmation_email_sent`),
  KEY `orders_tickets_generated_index` (`tickets_generated`),
  KEY `orders_confirmation_email_tracking_id_index` (`confirmation_email_tracking_id`),
  KEY `orders_confirmed_by_admin_id_foreign` (`confirmed_by_admin_id`),
  KEY `idx_coupon` (`coupon_id`),
  KEY `orders_staff_id_foreign` (`staff_id`),
  KEY `orders_order_reference_index` (`order_reference`),
  KEY `orders_has_been_reseated_index` (`has_been_reseated`),
  CONSTRAINT `orders_confirmed_by_admin_id_foreign` FOREIGN KEY (`confirmed_by_admin_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `orders_coupon_id_foreign` FOREIGN KEY (`coupon_id`) REFERENCES `coupons` (`id`) ON DELETE SET NULL,
  CONSTRAINT `orders_created_by_admin_id_foreign` FOREIGN KEY (`created_by_admin_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ownership_transfer_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ownership_transfer_requests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `order_id` bigint unsigned NOT NULL,
  `event_id` bigint unsigned NOT NULL,
  `current_owner_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `current_owner_email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `new_owner_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `new_owner_email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('pending','approved','rejected','completed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `reviewed_by` bigint unsigned DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `rejection_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `seat_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ownership_transfer_requests_reviewed_by_foreign` (`reviewed_by`),
  KEY `ownership_transfer_requests_ticket_id_index` (`ticket_id`),
  KEY `ownership_transfer_requests_order_id_index` (`order_id`),
  KEY `ownership_transfer_requests_event_id_index` (`event_id`),
  KEY `ownership_transfer_requests_current_owner_email_index` (`current_owner_email`),
  KEY `ownership_transfer_requests_new_owner_email_index` (`new_owner_email`),
  KEY `ownership_transfer_requests_status_index` (`status`),
  CONSTRAINT `ownership_transfer_requests_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `ownership_transfer_requests_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `ownership_transfer_requests_reviewed_by_foreign` FOREIGN KEY (`reviewed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `password_resets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `password_resets` (
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  KEY `password_resets_email_index` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `payment_audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `payment_audit_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `payment_transaction_id` bigint unsigned DEFAULT NULL,
  `order_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `action` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `old_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `new_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `source` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `trigger_event_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `action_at` timestamp NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_audit_payment_id` (`payment_transaction_id`),
  KEY `idx_audit_order_id` (`order_id`),
  KEY `idx_audit_user_id` (`user_id`),
  KEY `idx_audit_action` (`action`),
  KEY `idx_audit_new_status` (`new_status`),
  KEY `idx_audit_action_at` (`action_at`),
  KEY `idx_audit_payment_timeline` (`payment_transaction_id`,`action_at`),
  KEY `idx_audit_order_timeline` (`order_id`,`action_at`),
  CONSTRAINT `payment_audit_logs_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payment_audit_logs_payment_transaction_id_foreign` FOREIGN KEY (`payment_transaction_id`) REFERENCES `payment_transactions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payment_audit_logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `payment_reconciliations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `payment_reconciliations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `reconciliation_date` date NOT NULL COMMENT 'Date being reconciled',
  `payment_gateway` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Payment gateway (stripe, paypal, etc.)',
  `total_database_transactions` int NOT NULL DEFAULT '0' COMMENT 'Total transactions in database',
  `total_database_amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Total amount in database',
  `total_gateway_transactions` int NOT NULL DEFAULT '0' COMMENT 'Total transactions reported by gateway',
  `total_gateway_amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Total amount reported by gateway',
  `transaction_count_difference` int NOT NULL DEFAULT '0' COMMENT 'Difference in transaction counts',
  `amount_difference` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Difference in amounts (database - gateway)',
  `discrepancies_found` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether discrepancies were found',
  `discrepancies_details` json DEFAULT NULL COMMENT 'JSON array of specific discrepancies',
  `status` enum('pending','processing','completed','failed','requires_review') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `report_file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path to exported reconciliation report',
  `processed_by` bigint unsigned DEFAULT NULL COMMENT 'User ID who processed',
  `processed_at` timestamp NULL DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `payment_reconciliations_reconciliation_date_index` (`reconciliation_date`),
  KEY `payment_reconciliations_payment_gateway_index` (`payment_gateway`),
  KEY `payment_reconciliations_status_index` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `payment_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `payment_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `payment_gateway` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transaction_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'External payment gateway transaction ID',
  `amount` decimal(10,2) NOT NULL COMMENT 'Transaction amount',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'EUR' COMMENT 'ISO 4217 currency code',
  `status` enum('pending','processing','completed','failed','refunded','partially_refunded') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `metadata` json DEFAULT NULL COMMENT 'Additional transaction metadata',
  `initiated_at` timestamp NULL DEFAULT NULL COMMENT 'When payment was initiated',
  `completed_at` timestamp NULL DEFAULT NULL COMMENT 'When payment completed successfully',
  `failed_at` timestamp NULL DEFAULT NULL COMMENT 'When payment failed',
  `failure_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Reason for payment failure',
  `webhook_received_at` timestamp NULL DEFAULT NULL COMMENT 'When webhook notification was received',
  `refund_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'External refund transaction ID',
  `refunded_at` timestamp NULL DEFAULT NULL COMMENT 'When refund was processed',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `data_retention_until` timestamp NULL DEFAULT NULL COMMENT 'Date when this record should be anonymized/deleted per GDPR',
  `is_anonymized` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether personal data has been anonymized',
  `anonymized_at` timestamp NULL DEFAULT NULL COMMENT 'When the record was anonymized',
  `anonymized_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Reason for anonymization (e.g., retention_policy, user_request)',
  PRIMARY KEY (`id`),
  UNIQUE KEY `payment_transactions_transaction_id_unique` (`transaction_id`),
  KEY `payment_transactions_order_id_index` (`order_id`),
  KEY `payment_transactions_payment_gateway_index` (`payment_gateway`),
  KEY `payment_transactions_status_index` (`status`),
  KEY `payment_transactions_transaction_id_index` (`transaction_id`),
  KEY `payment_transactions_initiated_at_index` (`initiated_at`),
  KEY `payment_transactions_data_retention_until_index` (`data_retention_until`),
  KEY `payment_transactions_is_anonymized_data_retention_until_index` (`is_anonymized`,`data_retention_until`),
  CONSTRAINT `payment_transactions_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `permission_overrides`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `permission_overrides` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `admin_id` bigint unsigned NOT NULL,
  `permission` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Permission key e.g. seats.block',
  `type` enum('grant','revoke') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'grant',
  `granted_by` bigint unsigned DEFAULT NULL,
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Why this override was created',
  `expires_at` timestamp NULL DEFAULT NULL COMMENT 'Null = permanent',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_admin_permission_override` (`admin_id`,`permission`),
  KEY `permission_overrides_granted_by_foreign` (`granted_by`),
  KEY `idx_admin_override_type` (`admin_id`,`type`),
  KEY `idx_expires_at` (`expires_at`),
  CONSTRAINT `permission_overrides_admin_id_foreign` FOREIGN KEY (`admin_id`) REFERENCES `admins` (`id`) ON DELETE CASCADE,
  CONSTRAINT `permission_overrides_granted_by_foreign` FOREIGN KEY (`granted_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `permissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `admin_id` int DEFAULT NULL,
  `value` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `parent` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `photos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `photos` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `file_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `status` tinyint NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `photos_user_id_foreign` (`user_id`),
  CONSTRAINT `photos_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `posts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `posts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'News/Announcement/Notification',
  `title` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'sample-blog.png',
  `body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `footer` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` tinyint NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `price_tiers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `price_tiers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `venue_template_id` bigint unsigned DEFAULT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `source_tier_id` bigint unsigned DEFAULT NULL,
  `color` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `seat_prefix` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Optional prefix for seat names (e.g., VIP, BOOTH, VVIP)',
  `display_order` int NOT NULL DEFAULT '0',
  `display_in_legend` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_tier` (`venue_template_id`,`color`),
  UNIQUE KEY `unique_gala_tier_color` (`event_id`,`color`),
  KEY `idx_venue_template` (`venue_template_id`),
  KEY `idx_price_tiers_event_id` (`event_id`),
  CONSTRAINT `price_tiers_venue_template_id_foreign` FOREIGN KEY (`venue_template_id`) REFERENCES `venue_templates` (`id`) ON DELETE SET NULL,
  CONSTRAINT `price_tiers_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `price_tiers_source_tier_id_foreign` FOREIGN KEY (`source_tier_id`) REFERENCES `price_tiers` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `qr_validations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `qr_validations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` bigint unsigned NOT NULL,
  `scanned_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `scanner_device` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `location` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_valid` tinyint(1) NOT NULL,
  `validation_result` json NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_ticket_scanned` (`ticket_id`,`scanned_at`),
  KEY `qr_validations_is_valid_index` (`is_valid`),
  CONSTRAINT `qr_validations_ticket_id_foreign` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `queue_merge_acts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `queue_merge_acts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `act1` bigint unsigned NOT NULL,
  `act2` bigint unsigned NOT NULL,
  `new_act_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `new_act_slug` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `queue_monitor`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `queue_monitor` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `job_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','running','completed','failed','retrying') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempts` int NOT NULL DEFAULT '0',
  `max_retries` int NOT NULL DEFAULT '3',
  `payload` json DEFAULT NULL,
  `exception` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `exception_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `failed_at` timestamp NULL DEFAULT NULL,
  `execution_time_ms` int DEFAULT NULL,
  `memory_peak` int DEFAULT NULL,
  `retry_at` timestamp NULL DEFAULT NULL,
  `retry_delay_seconds` int DEFAULT NULL,
  `retry_strategy` enum('fixed','exponential','custom') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'exponential',
  `alert_sent` tinyint(1) NOT NULL DEFAULT '0',
  `alert_sent_at` timestamp NULL DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `correlation_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `batch_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `queue_monitor_job_id_index` (`job_id`),
  KEY `queue_monitor_job_name_index` (`job_name`),
  KEY `queue_monitor_queue_index` (`queue`),
  KEY `queue_monitor_status_index` (`status`),
  KEY `queue_monitor_created_at_index` (`created_at`),
  KEY `queue_monitor_failed_at_index` (`failed_at`),
  KEY `queue_monitor_status_queue_index` (`status`,`queue`),
  KEY `queue_monitor_job_name_status_index` (`job_name`,`status`),
  KEY `queue_monitor_correlation_id_index` (`correlation_id`),
  KEY `queue_monitor_batch_id_index` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `reseating_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `reseating_log` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `old_seats` json NOT NULL COMMENT 'Array of old seat IDs with details',
  `new_seats` json NOT NULL COMMENT 'Array of new seat IDs with details',
  `price_difference` decimal(10,2) NOT NULL COMMENT 'Positive = upgrade, negative = downgrade, zero = free swap',
  `adjustment_type` enum('upgrade','downgrade','none') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Manager-provided reason for reseating',
  `staff_id` bigint unsigned NOT NULL COMMENT 'Staff who performed reseating',
  `manager_approval_token` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Manager approval JWT token',
  `charges_waived` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if manager waived upgrade charges',
  `reseated_at` timestamp NOT NULL COMMENT 'When reseating was completed',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `reseating_log_staff_id_foreign` (`staff_id`),
  KEY `reseating_log_reseated_at_index` (`reseated_at`),
  KEY `reseating_log_order_id_reseated_at_index` (`order_id`,`reseated_at`),
  KEY `reseating_log_order_id_index` (`order_id`),
  KEY `reseating_log_adjustment_type_index` (`adjustment_type`),
  CONSTRAINT `reseating_log_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `reseating_log_staff_id_foreign` FOREIGN KEY (`staff_id`) REFERENCES `admins` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `scanner_devices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `scanner_devices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `device_uuid` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'iOS identifierForVendor (UUID v4 format)',
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Human-readable device name (e.g., "iPhone 12 Pro")',
  `device_info` json DEFAULT NULL COMMENT 'Device fingerprinting info (user agent, screen, timezone, etc.)',
  `scanner_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Human-readable name (e.g., "Gate A Entrance")',
  `nickname` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `current_operator` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `operator_updated_at` timestamp NULL DEFAULT NULL,
  `operator_history` json DEFAULT NULL,
  `pin_code_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Bcrypt hash of 4-6 digit PIN (NEVER plain text)',
  `staff_id` bigint unsigned DEFAULT NULL COMMENT 'FK to admins.id (optional staff member assignment)',
  `zone_id` bigint unsigned DEFAULT NULL COMMENT 'FK to scanner_zones.id (nullable for backward compatibility)',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Active status (true=active, false=deactivated)',
  `deactivated_at` timestamp NULL DEFAULT NULL COMMENT 'When device was deactivated',
  `deactivation_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Reason for deactivation (e.g., "Device lost/stolen")',
  `last_used_at` timestamp NULL DEFAULT NULL COMMENT 'Last successful scan (updated on every ticket scan)',
  `first_seen_at` timestamp NULL DEFAULT NULL COMMENT 'When device first logged in to zone',
  `last_seen_at` timestamp NULL DEFAULT NULL COMMENT 'Last activity timestamp (updated on each scan)',
  `total_scans` int NOT NULL DEFAULT '0' COMMENT 'Total number of tickets scanned by this device',
  `is_flagged` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Device flagged for suspicious activity',
  `flag_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Reason for flagging (e.g., "Idle too long", "Suspicious scan rate")',
  `failed_login_attempts` int NOT NULL DEFAULT '0' COMMENT 'Count of failed login attempts (reset on success)',
  `last_failed_login_at` timestamp NULL DEFAULT NULL COMMENT 'Timestamp of last failed login',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Admin notes about device (e.g., "Main entrance scanner, iPhone 13")',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `scanner_devices_device_uuid_unique` (`device_uuid`),
  KEY `idx_device_uuid` (`device_uuid`),
  KEY `idx_is_active` (`is_active`),
  KEY `idx_staff_id` (`staff_id`),
  KEY `idx_last_used_at` (`last_used_at`),
  KEY `idx_scanner_devices_zone_id` (`zone_id`),
  KEY `idx_scanner_devices_is_flagged` (`is_flagged`),
  KEY `idx_scanner_devices_last_seen_at` (`last_seen_at`),
  CONSTRAINT `fk_scanner_devices_staff_id` FOREIGN KEY (`staff_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_scanner_devices_zone_id` FOREIGN KEY (`zone_id`) REFERENCES `scanner_zones` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Scanner device registrations for ticket scanning auth';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `scanner_zones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `scanner_zones` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL COMMENT 'FK to events.id',
  `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Zone name (e.g., "Main Entrance", "VIP Door")',
  `pin_code` char(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '6-digit PIN code (stored plain for admin display)',
  `permissions` json NOT NULL DEFAULT (_utf8mb4'[]'),
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Zone active status',
  `active_from` timestamp NULL DEFAULT NULL COMMENT 'Zone activation start time',
  `active_until` timestamp NULL DEFAULT NULL COMMENT 'Zone activation end time',
  `pin_rotated_at` timestamp NULL DEFAULT NULL COMMENT 'Last PIN rotation timestamp',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_scanner_zones_event_id` (`event_id`),
  KEY `idx_scanner_zones_event_pin` (`event_id`,`pin_code`),
  KEY `idx_scanner_zones_is_active` (`is_active`),
  CONSTRAINT `fk_scanner_zones_event_id` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Scanner zones for event-based authentication';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `seat_reassignments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `seat_reassignments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_item_id` bigint unsigned NOT NULL COMMENT 'Reference to order_items.id',
  `original_seat_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Original seat UUID from seats table',
  `new_seat_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'New seat UUID from seats table',
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Reason for seat reassignment',
  `status` enum('pending','approved','rejected','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending' COMMENT 'Reassignment approval status',
  `reassigned_by` bigint unsigned NOT NULL COMMENT 'Admin ID who initiated reassignment',
  `reassigned_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When reassignment was initiated',
  `approved_by` bigint unsigned DEFAULT NULL COMMENT 'Admin ID who approved/rejected',
  `approved_at` timestamp NULL DEFAULT NULL COMMENT 'When reassignment was approved/rejected',
  `approval_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Notes from approver',
  `customer_notified` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether customer was notified',
  `customer_notified_at` timestamp NULL DEFAULT NULL COMMENT 'When customer was notified',
  `metadata` json DEFAULT NULL COMMENT 'Additional JSON metadata',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `seat_reassignments_order_item_id_index` (`order_item_id`),
  KEY `seat_reassignments_original_seat_id_index` (`original_seat_id`),
  KEY `seat_reassignments_new_seat_id_index` (`new_seat_id`),
  KEY `seat_reassignments_status_index` (`status`),
  KEY `seat_reassignments_reassigned_by_index` (`reassigned_by`),
  KEY `seat_reassignments_approved_by_index` (`approved_by`),
  KEY `seat_reassignments_reassigned_at_index` (`reassigned_at`),
  KEY `seat_reassignments_status_reassigned_at_index` (`status`,`reassigned_at`),
  KEY `seat_reassignments_order_item_id_status_index` (`order_item_id`,`status`),
  CONSTRAINT `seat_reassignments_order_item_id_foreign` FOREIGN KEY (`order_item_id`) REFERENCES `order_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `seat_reservations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `seat_reservations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `seat_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('held','booked','shadow_sold','blocked','cancelled','reserved','confirmed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'held',
  `reservation_type` enum('public','admin') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'public' COMMENT 'Type of reservation: public (customer-initiated) or admin (VIP white-glove)',
  `hold_token` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `invoice_url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Stripe payment link URL for admin reservations',
  `payment_intent_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Stripe PaymentIntent ID for admin reservations (required for invoice payment flow)',
  `payment_mode` enum('immediate','invoice') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'immediate' COMMENT 'Payment type: immediate (Stripe/Revolut) or invoice (VIP bank transfer)',
  `payment_gateway` enum('stripe','revolut','paypal','nbe') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'stripe' COMMENT 'Payment gateway selection for immediate mode reservations',
  `revolut_order_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Revolut order ID for admin invoice payments',
  `expires_at` timestamp NULL DEFAULT NULL,
  `released_at` timestamp NULL DEFAULT NULL,
  `payment_started_at` timestamp NULL DEFAULT NULL COMMENT 'When payment intent creation began (prevents cleanup during 3DS)',
  `order_id` bigint unsigned DEFAULT NULL,
  `user_session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `admin_user_id` bigint unsigned DEFAULT NULL COMMENT 'Admin user who created this reservation (admin reservations only)',
  `price_snapshot` decimal(10,2) DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Customer-visible note for blocked/unavailable seats',
  `coupon_id` bigint unsigned DEFAULT NULL COMMENT 'Which coupon was applied to this reservation',
  `discount_applied` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Discount amount locked in at hold time',
  `coupon_locked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'If true, honor discount even if coupon now invalid',
  `coupon_locked_at` timestamp NULL DEFAULT NULL COMMENT 'When coupon was locked (for audit trail)',
  `currency` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '£',
  `uses_custom_pricing` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether this reservation uses custom/override pricing',
  `include_booking_fee` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Whether booking fee (2.5%) is included in this reservation',
  `include_tax` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Whether tax (21% VAT) is included in this reservation',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_event_seat` (`event_id`,`seat_id`),
  KEY `seat_reservations_order_id_foreign` (`order_id`),
  KEY `seat_reservations_user_id_foreign` (`user_id`),
  KEY `seat_reservations_expires_at_index` (`expires_at`),
  KEY `seat_reservations_status_expires_at_index` (`expires_at`),
  KEY `idx_sr_session_id` (`session_id`),
  KEY `idx_sr_event_status` (`event_id`,`status`),
  KEY `idx_sr_created_at` (`created_at`),
  KEY `idx_sr_hold_token` (`hold_token`),
  KEY `idx_payment_started` (`payment_started_at`),
  KEY `seat_reservations_payment_intent_id_index` (`payment_intent_id`),
  KEY `seat_reservations_revolut_order_id_index` (`revolut_order_id`),
  KEY `seat_reservations_coupon_id_foreign` (`coupon_id`),
  KEY `idx_coupon_lock_cleanup` (`status`,`coupon_locked`,`expires_at`),
  KEY `fk_seat_reservations_admin_user` (`admin_user_id`),
  CONSTRAINT `fk_seat_reservations_admin_user` FOREIGN KEY (`admin_user_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `seat_reservations_coupon_id_foreign` FOREIGN KEY (`coupon_id`) REFERENCES `coupons` (`id`) ON DELETE SET NULL,
  CONSTRAINT `seat_reservations_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `seat_reservations_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `seat_state_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `seat_state_log` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `seat_ids` json NOT NULL COMMENT 'Array of seat IDs affected by this action',
  `action` enum('shadow_sold','blocked','unblocked','soft_blocked','hard_blocked') COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Reason for state change',
  `staff_id` bigint unsigned NOT NULL COMMENT 'Staff who performed action',
  `manager_approval_token` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Manager JWT token (for shadow sold)',
  `blocked_until` timestamp NULL DEFAULT NULL COMMENT 'Block expiry timestamp',
  `action_at` timestamp NOT NULL COMMENT 'When action was performed',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `seat_state_log_staff_id_foreign` (`staff_id`),
  KEY `seat_state_log_action_at_index` (`action_at`),
  KEY `seat_state_log_event_id_action_at_index` (`event_id`,`action_at`),
  KEY `seat_state_log_event_id_index` (`event_id`),
  KEY `seat_state_log_action_index` (`action`),
  CONSTRAINT `seat_state_log_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `seat_state_log_staff_id_foreign` FOREIGN KEY (`staff_id`) REFERENCES `admins` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `seat_transfer_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `seat_transfer_requests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `event_id` bigint unsigned NOT NULL,
  `from_seat_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `to_seat_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `customer_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `original_price` decimal(10,2) NOT NULL,
  `new_price` decimal(10,2) NOT NULL,
  `upgrade_fee` decimal(10,2) NOT NULL DEFAULT '0.00',
  `price_difference` decimal(10,2) NOT NULL DEFAULT '0.00',
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` enum('pending','approved','rejected','completed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `reviewed_by` bigint unsigned DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `admin_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `rejection_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `completed_at` timestamp NULL DEFAULT NULL,
  `completion_reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `seat_transfer_requests_reviewed_by_foreign` (`reviewed_by`),
  KEY `seat_transfer_requests_order_id_index` (`order_id`),
  KEY `seat_transfer_requests_event_id_index` (`event_id`),
  KEY `seat_transfer_requests_from_seat_id_index` (`from_seat_id`),
  KEY `seat_transfer_requests_to_seat_id_index` (`to_seat_id`),
  KEY `seat_transfer_requests_user_id_index` (`user_id`),
  KEY `seat_transfer_requests_session_id_index` (`session_id`),
  KEY `seat_transfer_requests_customer_email_index` (`customer_email`),
  KEY `seat_transfer_requests_status_index` (`status`),
  CONSTRAINT `seat_transfer_requests_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `seat_transfer_requests_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `seat_transfer_requests_reviewed_by_foreign` FOREIGN KEY (`reviewed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `seat_transfer_requests_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `seats`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `seats` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `seat_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `parent_table_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_id` bigint unsigned NOT NULL,
  `row_letter` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `seat_number` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `seat_type` enum('individual','table','table_child') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'individual',
  `price` decimal(10,2) NOT NULL,
  `price_tier_id` bigint unsigned DEFAULT NULL,
  `price_assigned_from_tier` decimal(10,2) DEFAULT NULL,
  `zone` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `parametric` json DEFAULT NULL,
  `child_seats` json DEFAULT NULL,
  `position` json DEFAULT NULL,
  `section_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_accessible` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `total_tables` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `blocked_reason` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Reason for blocking (broken, accessibility, vip_hold, etc)',
  `blocked_until` timestamp NULL DEFAULT NULL COMMENT 'When block expires (null = permanent)',
  PRIMARY KEY (`id`),
  UNIQUE KEY `seats_event_id_seat_id_unique` (`event_id`,`seat_id`),
  UNIQUE KEY `seats_event_seat_unique` (`event_id`,`seat_id`),
  KEY `seats_event_id_is_active_index` (`event_id`,`is_active`),
  KEY `seats_seat_id_index` (`seat_id`),
  KEY `seats_event_id_index` (`event_id`),
  KEY `seats_event_id_seat_type_index` (`event_id`,`seat_type`),
  KEY `seats_event_id_section_id_index` (`event_id`,`section_id`),
  KEY `seats_parent_table_id_seat_type_index` (`parent_table_id`,`seat_type`),
  KEY `seats_parent_table_id_index` (`parent_table_id`),
  KEY `seats_section_id_index` (`section_id`),
  KEY `idx_seats_price` (`price`),
  KEY `idx_seats_event_price` (`event_id`,`price`),
  KEY `idx_price_tier` (`price_tier_id`),
  KEY `seats_blocked_until_index` (`blocked_until`),
  CONSTRAINT `seats_price_tier_id_foreign` FOREIGN KEY (`price_tier_id`) REFERENCES `price_tiers` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `group` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'string',
  `label` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_encrypted` tinyint(1) NOT NULL DEFAULT '0',
  `is_editable` tinyint(1) NOT NULL DEFAULT '1',
  `is_visible` tinyint(1) NOT NULL DEFAULT '1',
  `requires_super_admin` tinyint(1) NOT NULL DEFAULT '0',
  `sort_order` int NOT NULL DEFAULT '0',
  `updated_by_admin_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `settings_group_key_unique` (`group`,`key`),
  KEY `settings_updated_by_admin_id_foreign` (`updated_by_admin_id`),
  KEY `settings_group_index` (`group`),
  CONSTRAINT `settings_updated_by_admin_id_foreign` FOREIGN KEY (`updated_by_admin_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `special_messages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `special_messages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `block` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `strava_users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `strava_users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `strava_id` bigint unsigned NOT NULL,
  `access_token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `refresh_token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `profile_photo` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `expires_at` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `strava_users_user_id_foreign` (`user_id`),
  CONSTRAINT `strava_users_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `stripe_webhook_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `stripe_webhook_events` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `received_at` timestamp NULL DEFAULT NULL,
  `processed_at` timestamp NULL DEFAULT NULL,
  `processing_result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `stripe_webhook_events_event_id_unique` (`event_id`),
  KEY `stripe_webhook_events_event_id_index` (`event_id`),
  KEY `stripe_webhook_events_event_type_index` (`event_type`),
  KEY `stripe_webhook_events_received_at_index` (`received_at`),
  KEY `stripe_webhook_events_processed_at_index` (`processed_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `support_conversation_labels`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `support_conversation_labels` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `conversation_id` bigint unsigned NOT NULL,
  `label_id` bigint unsigned NOT NULL,
  `added_by_admin_id` bigint unsigned DEFAULT NULL COMMENT 'Admin who added this label',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_conversation_label` (`conversation_id`,`label_id`),
  KEY `support_conversation_labels_added_by_admin_id_foreign` (`added_by_admin_id`),
  KEY `support_conversation_labels_label_id_index` (`label_id`),
  CONSTRAINT `support_conversation_labels_added_by_admin_id_foreign` FOREIGN KEY (`added_by_admin_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  CONSTRAINT `support_conversation_labels_conversation_id_foreign` FOREIGN KEY (`conversation_id`) REFERENCES `support_conversations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `support_conversation_labels_label_id_foreign` FOREIGN KEY (`label_id`) REFERENCES `support_labels` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `support_conversations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `support_conversations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `version` int NOT NULL DEFAULT '1',
  `order_id` bigint unsigned DEFAULT NULL,
  `customer_id` bigint unsigned DEFAULT NULL,
  `customer_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Order Support',
  `status` enum('open','pending','resolved','closed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `priority` enum('low','normal','high','urgent') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'normal',
  `last_customer_message_at` timestamp NULL DEFAULT NULL,
  `window_expires_at` timestamp NULL DEFAULT NULL,
  `is_window_active` tinyint(1) NOT NULL DEFAULT '0',
  `assigned_to_user_id` bigint unsigned DEFAULT NULL,
  `first_response_at` timestamp NULL DEFAULT NULL,
  `first_response_time_seconds` int DEFAULT NULL,
  `resolved_at` timestamp NULL DEFAULT NULL,
  `total_response_time_seconds` int DEFAULT NULL,
  `customer_message_count` int NOT NULL DEFAULT '0',
  `agent_message_count` int NOT NULL DEFAULT '0',
  `tags` json DEFAULT NULL,
  `internal_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `support_conversations_order_id_index` (`order_id`),
  KEY `support_conversations_customer_id_index` (`customer_id`),
  KEY `support_conversations_customer_phone_index` (`customer_phone`),
  KEY `support_conversations_status_index` (`status`),
  KEY `support_conversations_assigned_to_user_id_index` (`assigned_to_user_id`),
  KEY `support_conversations_is_window_active_window_expires_at_index` (`is_window_active`,`window_expires_at`),
  KEY `support_conversations_created_at_index` (`created_at`),
  KEY `support_conversations_version_index` (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `support_labels`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `support_labels` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Machine-readable name, e.g., "vip"',
  `display_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Human-readable name, e.g., "VIP Customer"',
  `color` varchar(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Hex color code, e.g., "#FFD700"',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Optional description of the label',
  `sort_order` int NOT NULL DEFAULT '0' COMMENT 'Display order in UI',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `support_labels_name_unique` (`name`),
  KEY `support_labels_sort_order_index` (`sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `teams`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `teams` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_entries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_entries` (
  `sequence` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `family_hash` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `should_display_on_index` tinyint(1) NOT NULL DEFAULT '1',
  `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` datetime DEFAULT NULL,
  PRIMARY KEY (`sequence`),
  UNIQUE KEY `telescope_entries_uuid_unique` (`uuid`),
  KEY `telescope_entries_batch_id_index` (`batch_id`),
  KEY `telescope_entries_family_hash_index` (`family_hash`),
  KEY `telescope_entries_created_at_index` (`created_at`),
  KEY `telescope_entries_type_should_display_on_index_index` (`type`,`should_display_on_index`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_entries_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_entries_tags` (
  `entry_uuid` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `tag` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`entry_uuid`,`tag`),
  KEY `telescope_entries_tags_tag_index` (`tag`),
  CONSTRAINT `telescope_entries_tags_entry_uuid_foreign` FOREIGN KEY (`entry_uuid`) REFERENCES `telescope_entries` (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_monitoring`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_monitoring` (
  `tag` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `template_versions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `template_versions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `venue_template_id` bigint unsigned NOT NULL,
  `version` int unsigned NOT NULL,
  `snapshot` json NOT NULL,
  `changed_fields` json DEFAULT NULL,
  `created_by` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_template_version` (`venue_template_id`,`version`),
  KEY `idx_template_version_history` (`venue_template_id`,`created_at`),
  CONSTRAINT `template_versions_venue_template_id_foreign` FOREIGN KEY (`venue_template_id`) REFERENCES `venue_templates` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_audit_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_subtype` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `severity` int NOT NULL DEFAULT '1',
  `ticket_id` bigint unsigned DEFAULT NULL,
  `ticket_tuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_id` bigint unsigned DEFAULT NULL,
  `order_item_id` bigint unsigned DEFAULT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `batch_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `user_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `admin_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `request_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `correlation_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `action` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `metadata` json DEFAULT NULL,
  `request_data` json DEFAULT NULL,
  `response_data` json DEFAULT NULL,
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `error_trace` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `auth_method` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `access_token_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `signature_valid` tinyint(1) DEFAULT NULL,
  `scanner_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `scanner_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `file_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `file_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `file_size` int DEFAULT NULL,
  `template_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `duration_ms` decimal(10,2) DEFAULT NULL,
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `old_values` json DEFAULT NULL,
  `new_values` json DEFAULT NULL,
  `change_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `download_token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `token_expires_at` timestamp NULL DEFAULT NULL,
  `download_count` int NOT NULL DEFAULT '0',
  `validation_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qr_data_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `validation_errors` json DEFAULT NULL,
  `job_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `queue_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `retry_count` int NOT NULL DEFAULT '0',
  `webhook_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `webhook_status_code` int DEFAULT NULL,
  `webhook_response` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_audit_logs_event_type_status_index` (`event_type`,`status`),
  KEY `ticket_audit_logs_ticket_id_event_type_index` (`ticket_id`,`event_type`),
  KEY `ticket_audit_logs_user_id_event_type_index` (`user_id`,`event_type`),
  KEY `ticket_audit_logs_created_at_event_type_index` (`created_at`,`event_type`),
  KEY `ticket_audit_logs_order_id_event_type_index` (`order_id`,`event_type`),
  KEY `ticket_audit_logs_batch_id_status_index` (`batch_id`,`status`),
  KEY `ticket_audit_logs_event_type_index` (`event_type`),
  KEY `ticket_audit_logs_status_index` (`status`),
  KEY `ticket_audit_logs_ticket_id_index` (`ticket_id`),
  KEY `ticket_audit_logs_ticket_tuid_index` (`ticket_tuid`),
  KEY `ticket_audit_logs_order_id_index` (`order_id`),
  KEY `ticket_audit_logs_order_item_id_index` (`order_item_id`),
  KEY `ticket_audit_logs_event_id_index` (`event_id`),
  KEY `ticket_audit_logs_batch_id_index` (`batch_id`),
  KEY `ticket_audit_logs_user_id_index` (`user_id`),
  KEY `ticket_audit_logs_ip_address_index` (`ip_address`),
  KEY `ticket_audit_logs_session_id_index` (`session_id`),
  KEY `ticket_audit_logs_request_id_index` (`request_id`),
  KEY `ticket_audit_logs_correlation_id_index` (`correlation_id`),
  KEY `ticket_audit_logs_download_token_index` (`download_token`),
  KEY `ticket_audit_logs_validation_code_index` (`validation_code`),
  KEY `ticket_audit_logs_job_id_index` (`job_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_booking`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_booking` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `booking_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `cust_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `cust_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `cust_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `billing_address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` bigint unsigned NOT NULL,
  `tuids` json DEFAULT NULL,
  `total_amount` double(8,2) NOT NULL,
  `status` tinyint NOT NULL DEFAULT '0' COMMENT 'allow only 0 / 1 for pending and paid',
  `ticket_document` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ticket_booking_booking_id_unique` (`booking_id`),
  KEY `ticket_booking_event_id_foreign` (`event_id`),
  CONSTRAINT `ticket_booking_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_download_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_download_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` enum('attempted','success','unauthorized','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `download_method` enum('direct','temporary_url') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_download_logs_ticket_id_index` (`ticket_id`),
  KEY `ticket_download_logs_order_id_index` (`order_id`),
  KEY `ticket_download_logs_user_id_index` (`user_id`),
  KEY `ticket_download_logs_status_index` (`status`),
  KEY `ticket_download_logs_created_at_index` (`created_at`),
  KEY `ticket_download_logs_ticket_id_status_index` (`ticket_id`,`status`),
  KEY `ticket_download_logs_user_id_created_at_index` (`user_id`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_generation_batches`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_generation_batches` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `batch_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('initializing','processing','completed','failed','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'initializing',
  `priority` enum('normal','high') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'normal',
  `template_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'standard',
  `total_orders` int NOT NULL DEFAULT '0',
  `valid_orders` int NOT NULL DEFAULT '0',
  `total_tickets` int NOT NULL DEFAULT '0',
  `completed_tickets` int NOT NULL DEFAULT '0',
  `failed_tickets` int NOT NULL DEFAULT '0',
  `progress_percentage` decimal(5,2) NOT NULL DEFAULT '0.00',
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `include_email` tinyint(1) NOT NULL DEFAULT '0',
  `webhook_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `invalid_orders` json DEFAULT NULL,
  `errors` json DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ticket_generation_batches_batch_id_unique` (`batch_id`),
  KEY `ticket_generation_batches_batch_id_index` (`batch_id`),
  KEY `ticket_generation_batches_status_index` (`status`),
  KEY `ticket_generation_batches_priority_index` (`priority`),
  KEY `ticket_generation_batches_created_at_index` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_price`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_price` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` double(8,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_price_event_id_foreign` (`event_id`),
  CONSTRAINT `ticket_price_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_reissuances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_reissuances` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` bigint unsigned NOT NULL,
  `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `issued_by` bigint unsigned DEFAULT NULL,
  `delivery_method` enum('email','download') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_reissuances_issued_by_foreign` (`issued_by`),
  KEY `ticket_reissuances_ticket_id_created_at_index` (`ticket_id`,`created_at`),
  CONSTRAINT `ticket_reissuances_issued_by_foreign` FOREIGN KEY (`issued_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `ticket_reissuances_ticket_id_foreign` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_security_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_security_events` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `ticket_id` bigint unsigned DEFAULT NULL,
  `details` json DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_security_events_event_type_index` (`event_type`),
  KEY `ticket_security_events_ticket_id_index` (`ticket_id`),
  KEY `ticket_security_events_created_at_index` (`created_at`),
  KEY `ticket_security_events_event_type_created_at_index` (`event_type`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` enum('standard','vip','wristband','digital') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `html_template` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `css_styles` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `dimensions` json NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `version` int NOT NULL DEFAULT '1',
  `accessibility_compliant` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_templates_type_is_active_index` (`type`,`is_active`),
  KEY `ticket_templates_version_index` (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_url_access_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_url_access_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` bigint unsigned NOT NULL,
  `token_jti` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `order_id` bigint unsigned DEFAULT NULL,
  `accessed_at` timestamp NOT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `metadata` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_url_access_logs_ticket_id_index` (`ticket_id`),
  KEY `ticket_url_access_logs_token_jti_index` (`token_jti`),
  KEY `ticket_url_access_logs_event_id_index` (`event_id`),
  KEY `ticket_url_access_logs_order_id_index` (`order_id`),
  KEY `ticket_url_access_logs_accessed_at_index` (`accessed_at`),
  KEY `ticket_url_access_logs_ticket_id_accessed_at_index` (`ticket_id`,`accessed_at`),
  KEY `ticket_url_access_logs_ip_address_accessed_at_index` (`ip_address`,`accessed_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_url_generation_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_url_generation_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` bigint unsigned NOT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `order_id` bigint unsigned DEFAULT NULL,
  `generated_by` bigint unsigned DEFAULT NULL,
  `expiry_minutes` int NOT NULL,
  `access_limit` int DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `generated_at` timestamp NOT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_url_generation_logs_ticket_id_index` (`ticket_id`),
  KEY `ticket_url_generation_logs_generated_by_index` (`generated_by`),
  KEY `ticket_url_generation_logs_generated_at_index` (`generated_at`),
  KEY `ticket_url_generation_logs_ticket_id_generated_at_index` (`ticket_id`,`generated_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_validations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_validations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `ticket_id` bigint unsigned NOT NULL,
  `line_item_id` bigint unsigned DEFAULT NULL,
  `tuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `validation_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('valid','invalid','duplicate','expired','tampered') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `scan_type` enum('entry','exit') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Type of scan: entry (IN) or exit (OUT)',
  `manual_override` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if this validation was a manual override by a manager',
  `override_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Manager-provided reason for manual override',
  `override_by_staff_id` bigint unsigned DEFAULT NULL COMMENT 'Admin ID who performed manual override',
  `override_approved_at` timestamp NULL DEFAULT NULL COMMENT 'When the manager approved the manual override',
  `scanner_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `scanner_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qr_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `signature_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `signature_valid` tinyint(1) NOT NULL DEFAULT '0',
  `validation_errors` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `validated_at` datetime NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `idempotency_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_idempotency_key` (`idempotency_key`),
  KEY `ticket_validations_ticket_id_index` (`ticket_id`),
  KEY `ticket_validations_tuid_index` (`tuid`),
  KEY `ticket_validations_event_id_index` (`event_id`),
  KEY `ticket_validations_validation_code_index` (`validation_code`),
  KEY `ticket_validations_validated_at_index` (`validated_at`),
  KEY `ticket_validations_status_index` (`status`),
  KEY `ticket_validations_line_item_id_index` (`line_item_id`),
  KEY `idx_validation_scan_lookup` (`validation_code`,`scan_type`,`status`),
  KEY `idx_validation_code` (`validation_code`),
  KEY `idx_manual_override` (`manual_override`),
  CONSTRAINT `ticket_validations_line_item_id_foreign` FOREIGN KEY (`line_item_id`) REFERENCES `order_line_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_verification_codes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_verification_codes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `verification_code` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Short unique code for QR/barcode',
  `line_item_id` bigint unsigned NOT NULL COMMENT 'Reference to order_line_items table',
  `order_id` bigint unsigned NOT NULL COMMENT 'Reference to orders table',
  `event_id` bigint unsigned NOT NULL COMMENT 'Event this ticket is for',
  `ticket_type` enum('qr','barcode','both') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'both' COMMENT 'Type of code generated',
  `status` enum('active','used','revoked','expired') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT 'Current status of verification code',
  `qr_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'JSON with minimal ticket info for QR',
  `barcode_data` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'CODE128 data for barcode',
  `barcode_format` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'CODE128' COMMENT 'Barcode format type',
  `hmac_signature` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'HMAC signature for tamper detection',
  `generated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When verification code was created',
  `expires_at` timestamp NULL DEFAULT NULL COMMENT 'Optional expiry (null = never expires)',
  `first_scanned_at` timestamp NULL DEFAULT NULL COMMENT 'First scan timestamp',
  `last_scanned_at` timestamp NULL DEFAULT NULL COMMENT 'Most recent scan timestamp',
  `scan_count` int unsigned NOT NULL DEFAULT '0' COMMENT 'Number of times scanned',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ticket_verification_codes_verification_code_unique` (`verification_code`),
  KEY `idx_event_status` (`event_id`,`status`),
  KEY `idx_order_status` (`order_id`,`status`),
  KEY `ticket_verification_codes_line_item_id_index` (`line_item_id`),
  KEY `ticket_verification_codes_order_id_index` (`order_id`),
  KEY `ticket_verification_codes_event_id_index` (`event_id`),
  KEY `ticket_verification_codes_status_index` (`status`),
  CONSTRAINT `ticket_verification_codes_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `ticket_verification_codes_line_item_id_foreign` FOREIGN KEY (`line_item_id`) REFERENCES `order_line_items` (`id`) ON DELETE CASCADE,
  CONSTRAINT `ticket_verification_codes_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ticket_wise_prices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket_wise_prices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `ticket_category_id` bigint unsigned NOT NULL,
  `per_ticket_price` bigint unsigned NOT NULL,
  `ticket_quantity` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `tickets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tickets` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `booking_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `tuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `ticket_status` enum('active','blocked','barred','revoked','transferred','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `is_blocked` tinyint(1) NOT NULL DEFAULT '0',
  `is_barred` tinyint(1) NOT NULL DEFAULT '0',
  `denial_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `blocked_at` timestamp NULL DEFAULT NULL,
  `barred_by` bigint unsigned DEFAULT NULL,
  `barred_at` timestamp NULL DEFAULT NULL,
  `security_alerts_count` int NOT NULL DEFAULT '0',
  `last_security_alert_at` timestamp NULL DEFAULT NULL,
  `blocked_by` bigint unsigned DEFAULT NULL,
  `blocked_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `unblocked_at` timestamp NULL DEFAULT NULL,
  `unblocked_by` bigint unsigned DEFAULT NULL,
  `ticket_type` enum('individual','party','group') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'individual' COMMENT 'Type of ticket: individual, party (child of a party ticket), or group',
  `parent_ticket_id` bigint unsigned DEFAULT NULL COMMENT 'For party tickets, reference to the parent ticket',
  `party_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Name for party/group bookings',
  `party_size` int unsigned DEFAULT NULL COMMENT 'Number of people in party/group booking',
  `used_at` datetime DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL,
  `pdf_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pdf_generated_at` timestamp NULL DEFAULT NULL,
  `template_version` int NOT NULL DEFAULT '1',
  `reissued_at` timestamp NULL DEFAULT NULL,
  `reissued_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reissue_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tickets_booking_id_unique` (`booking_id`),
  KEY `tickets_reissued_at_index` (`reissued_at`),
  KEY `tickets_reissued_by_index` (`reissued_by`),
  KEY `tickets_pdf_generated_at_index` (`pdf_generated_at`),
  KEY `idx_status` (`status`),
  KEY `idx_event_status` (`event_id`,`status`),
  KEY `idx_booking_event` (`booking_id`,`event_id`),
  KEY `idx_used_at` (`used_at`),
  KEY `idx_expires_at` (`expires_at`),
  KEY `idx_ticket_type` (`ticket_type`),
  KEY `idx_parent_ticket` (`parent_ticket_id`),
  KEY `tickets_unblocked_by_foreign` (`unblocked_by`),
  KEY `tickets_blocked_at_index` (`blocked_at`),
  KEY `tickets_blocked_by_index` (`blocked_by`),
  KEY `tickets_unblocked_at_index` (`unblocked_at`),
  KEY `tickets_is_blocked_index` (`is_blocked`),
  KEY `tickets_is_barred_index` (`is_barred`),
  KEY `tickets_is_blocked_is_barred_index` (`is_blocked`,`is_barred`),
  KEY `blocked_at_index` (`blocked_at`),
  CONSTRAINT `tickets_blocked_by_foreign` FOREIGN KEY (`blocked_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `tickets_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`),
  CONSTRAINT `tickets_parent_ticket_id_foreign` FOREIGN KEY (`parent_ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `tickets_unblocked_by_foreign` FOREIGN KEY (`unblocked_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `tshirt_trackings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tshirt_trackings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `registration_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `user_audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_audit_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `action` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `old_value` text COLLATE utf8mb4_unicode_ci,
  `new_value` text COLLATE utf8mb4_unicode_ci,
  `metadata` json DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_audit_logs_user_id_action_index` (`user_id`,`action`),
  KEY `user_audit_logs_action_created_at_index` (`action`,`created_at`),
  KEY `user_audit_logs_user_id_index` (`user_id`),
  KEY `user_audit_logs_action_index` (`action`),
  KEY `user_audit_logs_created_at_index` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `user_consents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_consents` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `consent_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `consent_given` tinyint(1) NOT NULL DEFAULT '0',
  `consent_version` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `source` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `consented_at` timestamp NULL DEFAULT NULL,
  `withdrawn_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_consents_user_id_consent_type_consent_given_index` (`user_id`,`consent_type`,`consent_given`),
  KEY `user_consents_email_consent_type_consent_given_index` (`email`,`consent_type`,`consent_given`),
  KEY `user_consents_user_id_index` (`user_id`),
  KEY `user_consents_email_index` (`email`),
  KEY `user_consents_consent_type_index` (`consent_type`),
  KEY `user_consents_consent_given_index` (`consent_given`),
  KEY `user_consents_consented_at_index` (`consented_at`),
  KEY `user_consents_withdrawn_at_index` (`withdrawn_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `user_groups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_groups` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `first_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password_changed_at` timestamp NULL DEFAULT NULL,
  `full_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `welcome_email_tracking_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `welcome_email_sent_at` timestamp NULL DEFAULT NULL,
  `welcome_email_opened_at` timestamp NULL DEFAULT NULL,
  `unsubscribed_from_marketing` tinyint(1) NOT NULL DEFAULT '0',
  `unsubscribed_at` timestamp NULL DEFAULT NULL,
  `marketing_emails` tinyint(1) NOT NULL DEFAULT '1',
  `marketing_sms` tinyint(1) NOT NULL DEFAULT '1',
  `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `gender` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `age_range` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `runner_walker` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `county` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `eircode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `corporate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tshirt` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_flag` tinyint(1) NOT NULL DEFAULT '0',
  `stripe_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `pin` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Hashed PIN for manager override authentication',
  `remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `age` int DEFAULT NULL,
  `entry_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `profile_photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_activity_distance` decimal(10,2) DEFAULT NULL,
  `last_activity_on` date DEFAULT NULL,
  `total_distance` decimal(10,2) DEFAULT NULL,
  `rank` int DEFAULT NULL,
  `registration_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `registration_ext_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `parent_user_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `suspension_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `suspended_at` timestamp NULL DEFAULT NULL,
  `suspended_by` bigint unsigned DEFAULT NULL,
  `locked_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Reason for account lock (e.g., failed PIN attempts)',
  `locked_at` timestamp NULL DEFAULT NULL COMMENT 'When account was locked',
  `device_info` json DEFAULT NULL,
  `activity_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_group` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`),
  UNIQUE KEY `users_username_unique` (`username`),
  KEY `users_email_index` (`email`),
  KEY `users_username_index` (`username`),
  KEY `users_entry_type_index` (`entry_type`),
  KEY `users_status_index` (`status`),
  KEY `users_email_verified_at_index` (`email_verified_at`),
  KEY `users_is_active_index` (`is_active`),
  KEY `idx_welcome_email_tracking_id` (`welcome_email_tracking_id`),
  KEY `idx_welcome_email_sent_at` (`welcome_email_sent_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `venue_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `venue_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned DEFAULT NULL,
  `venue_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Venue Template',
  `version` int NOT NULL DEFAULT '1',
  `status` enum('draft','published','archived') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `save_type` enum('manual','auto') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'manual',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `author` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `template_data` json DEFAULT NULL,
  `sections_data` json DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `total_seats` int NOT NULL DEFAULT '0',
  `total_tables` int NOT NULL DEFAULT '0',
  `total_capacity` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_published` tinyint(1) NOT NULL DEFAULT '0',
  `published_at` timestamp NULL DEFAULT NULL,
  `locked_at` timestamp NULL DEFAULT NULL COMMENT 'Timestamp when template was locked',
  `locked_reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Reason for lock (e.g., in_use_by_gala_123)',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `venue_templates_event_id_is_active_index` (`event_id`,`is_active`),
  KEY `venue_templates_event_id_index` (`event_id`),
  KEY `venue_templates_event_id_version_index` (`event_id`,`version`),
  KEY `venue_templates_event_id_status_index` (`event_id`,`status`),
  KEY `venue_templates_event_id_version_status_index` (`event_id`,`version`,`status`),
  KEY `idx_venue_templates_venue_id` (`venue_id`),
  KEY `idx_venue_templates_venue_active` (`venue_id`,`is_active`),
  KEY `idx_venue_templates_venue_status` (`venue_id`,`status`),
  KEY `idx_venue_templates_venue_version` (`venue_id`,`version`),
  CONSTRAINT `fk_venue_templates_venue_id` FOREIGN KEY (`venue_id`) REFERENCES `venues` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `venue_themes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `venue_themes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `theme_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `config` json NOT NULL,
  `is_global` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `venue_id` bigint unsigned DEFAULT NULL,
  `event_id` bigint unsigned DEFAULT NULL,
  `author` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1.0.0',
  `mode` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'custom',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `venue_themes_theme_id_unique` (`theme_id`),
  KEY `venue_themes_is_global_is_active_index` (`is_global`,`is_active`),
  KEY `venue_themes_venue_id_is_active_index` (`venue_id`,`is_active`),
  KEY `venue_themes_event_id_is_active_index` (`event_id`,`is_active`),
  KEY `venue_themes_name_index` (`name`),
  KEY `venue_themes_is_global_index` (`is_global`),
  KEY `venue_themes_is_active_index` (`is_active`),
  KEY `venue_themes_venue_id_index` (`venue_id`),
  KEY `venue_themes_event_id_index` (`event_id`),
  KEY `venue_themes_mode_index` (`mode`),
  CONSTRAINT `venue_themes_venue_id_foreign` FOREIGN KEY (`venue_id`) REFERENCES `venues` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `venues`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `venues` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `default_theme_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `street_address` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Street number and name (required for Revolut)',
  `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `region` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'State, province, or region (optional for Revolut)',
  `country` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `postal_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country_code` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'ISO 3166-1 alpha-2 country code (GB, US, FR, etc.)',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `capacity` int DEFAULT NULL,
  `contact_info` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `venues_default_theme_id_foreign` (`default_theme_id`),
  KEY `venues_country_code_index` (`country_code`),
  CONSTRAINT `venues_default_theme_id_foreign` FOREIGN KEY (`default_theme_id`) REFERENCES `venue_themes` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `verified_financial_entries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `verified_financial_entries` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned DEFAULT NULL,
  `type` enum('bank_transfer','cash','adjustment') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Type of manual entry',
  `status` enum('pending','verified','rejected') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending' COMMENT 'Verification status',
  `entry_date` date NOT NULL COMMENT 'Date the payment/entry occurred',
  `amount` decimal(12,2) NOT NULL COMMENT 'Amount in major currency units (e.g., 100.50)',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'GBP' COMMENT 'ISO 4217 currency code',
  `reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Bank reference, receipt number, etc.',
  `payer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Name of payer/customer',
  `verified_by` bigint unsigned DEFAULT NULL COMMENT 'Admin who verified/rejected this entry',
  `verified_at` timestamp NULL DEFAULT NULL COMMENT 'When the entry was verified/rejected',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Free-form notes about this entry',
  `document_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path to supporting document (receipt, bank statement)',
  `metadata` json DEFAULT NULL COMMENT 'Additional structured data',
  `created_by` bigint unsigned DEFAULT NULL COMMENT 'Admin who created this entry',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `vfe_event_type_date_idx` (`event_id`,`type`,`entry_date`),
  KEY `vfe_status_date_idx` (`status`,`entry_date`),
  KEY `vfe_date_type_idx` (`entry_date`,`type`),
  KEY `verified_financial_entries_verified_by_foreign` (`verified_by`),
  KEY `verified_financial_entries_created_by_foreign` (`created_by`),
  CONSTRAINT `verified_financial_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  CONSTRAINT `verified_financial_entries_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL,
  CONSTRAINT `verified_financial_entries_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `admins` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `waitlist_submissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `waitlist_submissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_id` bigint unsigned NOT NULL,
  `full_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `seat_preferences` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Text description of desired seats (e.g., "Table 5, seats 1-4" or "VIP section")',
  `reason_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Why they want these seats, special requests',
  `status` enum('pending','contacted','resolved') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending' COMMENT 'Admin response status: pending=not contacted, contacted=admin replied, resolved=resolved/closed',
  `contacted_at` timestamp NULL DEFAULT NULL COMMENT 'When admin marked as contacted',
  `contacted_by` bigint unsigned DEFAULT NULL COMMENT 'Admin user who marked as contacted',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'For spam prevention',
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'For analytics',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL COMMENT 'Soft deletes for GDPR compliance',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_email_per_event` (`email`,`event_id`),
  KEY `idx_event_id` (`event_id`),
  KEY `idx_email` (`email`),
  KEY `idx_created_at` (`created_at`),
  KEY `fk_waitlist_contacted_by` (`contacted_by`),
  CONSTRAINT `fk_waitlist_contacted_by` FOREIGN KEY (`contacted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_waitlist_event` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `webhook_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `webhook_events` (
  `event_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `payment_intent_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'EDGE-013 FIX: Payment Intent ID for deduplication',
  `payload` json DEFAULT NULL,
  `status` enum('pending','processing','processed','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `retry_count` int NOT NULL DEFAULT '0',
  `received_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `processed_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`event_id`),
  KEY `webhook_events_event_type_received_at_index` (`event_type`,`received_at`),
  KEY `webhook_events_status_received_at_index` (`status`,`received_at`),
  KEY `webhook_events_processed_at_index` (`processed_at`),
  KEY `webhook_events_payment_intent_id_index` (`payment_intent_id`),
  KEY `idx_webhook_dedup` (`event_type`(100),`payment_intent_id`(100))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `whats_app_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `whats_app_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `conversation_id` bigint unsigned DEFAULT NULL,
  `order_id` bigint unsigned DEFAULT NULL,
  `customer_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `message_body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `media_url` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `twilio_sid` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Unique Twilio message SID for idempotency',
  `direction` enum('inbound','outbound') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'queued',
  `template_sid` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Twilio Content SID if template used',
  `cost_amount` decimal(10,4) NOT NULL DEFAULT '0.0000' COMMENT 'Message cost from Twilio',
  `cost_currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `sent_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `whats_app_logs_twilio_sid_unique` (`twilio_sid`),
  KEY `customer_messages` (`customer_phone`,`created_at`),
  KEY `message_status` (`direction`,`status`),
  KEY `whats_app_logs_conversation_id_index` (`conversation_id`),
  KEY `whats_app_logs_order_id_index` (`order_id`),
  KEY `whats_app_logs_customer_phone_index` (`customer_phone`),
  KEY `whats_app_logs_direction_index` (`direction`),
  KEY `whats_app_logs_status_index` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `whatsapp_cost_tracker`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `whatsapp_cost_tracker` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `period_type` enum('hour','day') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `period_start` timestamp NOT NULL,
  `period_end` timestamp NOT NULL,
  `message_count` int NOT NULL DEFAULT '0',
  `total_cost` decimal(10,4) NOT NULL DEFAULT '0.0000',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `circuit_broken` tinyint(1) NOT NULL DEFAULT '0',
  `circuit_broken_at` timestamp NULL DEFAULT NULL,
  `inbound_count` int NOT NULL DEFAULT '0',
  `outbound_count` int NOT NULL DEFAULT '0',
  `template_count` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `whatsapp_cost_tracker_period_type_period_start_unique` (`period_type`,`period_start`),
  KEY `whatsapp_cost_tracker_period_type_period_start_period_end_index` (`period_type`,`period_start`,`period_end`),
  KEY `whatsapp_cost_tracker_period_start_index` (`period_start`),
  KEY `whatsapp_cost_tracker_circuit_broken_index` (`circuit_broken`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `whatsapp_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `whatsapp_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned DEFAULT NULL,
  `conversation_id` bigint unsigned DEFAULT NULL,
  `customer_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `message_body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `twilio_sid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `template_sid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('queued','sent','delivered','read','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'queued',
  `direction` enum('outbound','inbound') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `media_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `media_content_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `media_size` int DEFAULT NULL,
  `read_at` timestamp NULL DEFAULT NULL,
  `sent_at` timestamp NULL DEFAULT NULL,
  `delivered_at` timestamp NULL DEFAULT NULL,
  `error_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cost_amount` decimal(10,4) DEFAULT NULL,
  `cost_currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `raw_payload` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `whatsapp_logs_twilio_sid_unique` (`twilio_sid`),
  KEY `whatsapp_logs_order_id_index` (`order_id`),
  KEY `whatsapp_logs_conversation_id_index` (`conversation_id`),
  KEY `whatsapp_logs_customer_phone_index` (`customer_phone`),
  KEY `whatsapp_logs_direction_status_index` (`direction`,`status`),
  KEY `whatsapp_logs_sent_at_index` (`sent_at`),
  KEY `whatsapp_logs_created_at_index` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `whatsapp_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `whatsapp_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `template_sid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `template_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `friendly_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('pending','approved','rejected','disabled','paused') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `language` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'en',
  `content_body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `variables` json DEFAULT NULL,
  `submitted_at` timestamp NULL DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `rejected_at` timestamp NULL DEFAULT NULL,
  `rejection_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `messages_sent` int NOT NULL DEFAULT '0',
  `last_used_at` timestamp NULL DEFAULT NULL,
  `last_synced_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `whatsapp_templates_template_sid_unique` (`template_sid`),
  KEY `whatsapp_templates_template_name_index` (`template_name`),
  KEY `whatsapp_templates_status_index` (`status`),
  KEY `whatsapp_templates_template_name_language_index` (`template_name`,`language`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- WARNING: can't read the INFORMATION_SCHEMA.libraries table. It's most probably an old server 8.0.45.
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

INSERT INTO `migrations` VALUES (1,'2014_10_12_000000_create_users_table',1);
INSERT INTO `migrations` VALUES (2,'2014_10_12_100000_create_password_resets_table',1);
INSERT INTO `migrations` VALUES (3,'2022_02_15_105028_create_fundraising_profiles_table',1);
INSERT INTO `migrations` VALUES (4,'2022_02_15_112347_create_fundraising_transactions_table',1);
INSERT INTO `migrations` VALUES (5,'2022_03_07_040816_modify_registration_ext',1);
INSERT INTO `migrations` VALUES (6,'2022_03_08_132523_create_photos_table',1);
INSERT INTO `migrations` VALUES (7,'2022_03_08_140817_modify_users',1);
INSERT INTO `migrations` VALUES (8,'2022_03_08_143720_create_faqs_table',1);
INSERT INTO `migrations` VALUES (9,'2022_03_08_163251_create_donation_amounts_table',1);
INSERT INTO `migrations` VALUES (10,'2022_03_15_041018_create_special_messages_table',1);
INSERT INTO `migrations` VALUES (11,'2022_03_16_090802_create_posts_table',1);
INSERT INTO `migrations` VALUES (12,'2022_03_23_081540_create_strava_users_table',1);
INSERT INTO `migrations` VALUES (13,'2022_03_24_061328_create_tshirt_trackings_table',1);
INSERT INTO `migrations` VALUES (14,'2022_03_28_053654_create_user_groups_table',1);
INSERT INTO `migrations` VALUES (15,'2022_04_13_104317_create_teams_table',1);
INSERT INTO `migrations` VALUES (16,'2022_08_24_152513_create_events_table',1);
INSERT INTO `migrations` VALUES (17,'2022_08_24_152536_create_acts_table',1);
INSERT INTO `migrations` VALUES (18,'2022_08_25_073206_create_clubs_table',1);
INSERT INTO `migrations` VALUES (19,'2022_08_25_075649_create_event_photos_table',1);
INSERT INTO `migrations` VALUES (20,'2022_08_25_085350_create_act_sponsor_photos_table',1);
INSERT INTO `migrations` VALUES (21,'2022_08_25_085418_create_ticket_booking_table',1);
INSERT INTO `migrations` VALUES (22,'2022_08_25_122500_create_ticket_price_table',1);
INSERT INTO `migrations` VALUES (23,'2022_08_25_124049_create_tickets_table',1);
INSERT INTO `migrations` VALUES (24,'2022_08_25_140000_create_carts_table',1);
INSERT INTO `migrations` VALUES (25,'2022_08_25_150000_create_permissions_table',1);
INSERT INTO `migrations` VALUES (26,'2022_08_25_160000_create_contents_table',1);
INSERT INTO `migrations` VALUES (27,'2022_08_26_110000_create_blog_categories_table',1);
INSERT INTO `migrations` VALUES (28,'2022_08_26_120000_create_blogs_table',1);
INSERT INTO `migrations` VALUES (29,'2022_08_26_130000_create_banners_table',1);
INSERT INTO `migrations` VALUES (30,'2022_12_02_054841_create_queue_merge_acts_table',1);
INSERT INTO `migrations` VALUES (31,'2023_07_05_172058_create_ticket_categories_table',1);
INSERT INTO `migrations` VALUES (32,'2023_07_05_193358_create_ticket_wise_prices_table',1);
INSERT INTO `migrations` VALUES (33,'2024_09_10_111500_add_unique_constraint_to_carts_table',1);
INSERT INTO `migrations` VALUES (34,'2025_09_09_100000_create_seat_reservations_table',1);
INSERT INTO `migrations` VALUES (35,'2025_09_09_105000_create_seats_table',1);
INSERT INTO `migrations` VALUES (36,'2025_09_09_110000_create_orders_table',1);
INSERT INTO `migrations` VALUES (37,'2025_09_09_120000_add_idempotency_key_to_orders_table',1);
INSERT INTO `migrations` VALUES (38,'2025_09_09_130000_make_user_id_nullable_in_orders_table',1);
INSERT INTO `migrations` VALUES (39,'2025_09_09_153015_create_cache_table',1);
INSERT INTO `migrations` VALUES (40,'2025_09_10_155059_create_order_items_table',1);
INSERT INTO `migrations` VALUES (41,'2025_09_10_155308_create_event_wise_seat_categories_table',1);
INSERT INTO `migrations` VALUES (42,'2025_09_12_225618_add_table_support_to_seats_table',1);
INSERT INTO `migrations` VALUES (43,'2025_09_12_230003_create_venue_templates_table',1);
INSERT INTO `migrations` VALUES (44,'2025_09_17_182524_add_shadow_sold_status_to_seat_reservations_table',1);
INSERT INTO `migrations` VALUES (45,'2025_09_23_140000_add_versioning_to_venue_templates',1);
INSERT INTO `migrations` VALUES (46,'2025_09_23_150000_fix_venue_templates_constraints',1);
INSERT INTO `migrations` VALUES (47,'2025_09_24_174638_create_admin_roles_table',1);
INSERT INTO `migrations` VALUES (48,'2025_09_24_174639_create_admins_table',1);
INSERT INTO `migrations` VALUES (49,'2025_09_24_175742_migrate_mbs_users_to_admin_system',1);
INSERT INTO `migrations` VALUES (50,'2025_09_24_180659_create_email_templates_table',1);
INSERT INTO `migrations` VALUES (51,'2025_09_24_183910_create_content_pages_table',1);
INSERT INTO `migrations` VALUES (52,'2025_09_26_163916_add_selling_period_columns_to_events_table',1);
INSERT INTO `migrations` VALUES (53,'2025_09_29_000000_add_reissue_fields_to_tickets_table',1);
INSERT INTO `migrations` VALUES (54,'2025_09_29_000001_create_email_templates_table',1);
INSERT INTO `migrations` VALUES (55,'2025_09_29_115701_create_ticket_templates_table',1);
INSERT INTO `migrations` VALUES (56,'2025_09_29_123239_add_pdf_tracking_to_tickets_table',1);
INSERT INTO `migrations` VALUES (57,'2025_09_29_123500_create_ticket_reissuances_table',1);
INSERT INTO `migrations` VALUES (58,'2025_09_29_124324_add_ticket_generation_status_to_order_items_table',1);
INSERT INTO `migrations` VALUES (59,'2025_09_29_140000_create_ticket_generation_batches_table',1);
INSERT INTO `migrations` VALUES (60,'2025_09_29_150000_create_ticket_download_logs_table',1);
INSERT INTO `migrations` VALUES (61,'2025_09_29_160000_create_ticket_url_access_logs_table',1);
INSERT INTO `migrations` VALUES (62,'2025_09_29_160001_create_ticket_url_generation_logs_table',1);
INSERT INTO `migrations` VALUES (63,'2025_09_29_160002_create_ticket_security_events_table',1);
INSERT INTO `migrations` VALUES (64,'2025_09_29_163525_create_jobs_table',1);
INSERT INTO `migrations` VALUES (65,'2025_09_29_163527_create_failed_jobs_table',1);
INSERT INTO `migrations` VALUES (66,'2025_09_29_163807_create_batch_jobs_table',1);
INSERT INTO `migrations` VALUES (67,'2025_09_29_170653_create_ticket_validations_table',1);
INSERT INTO `migrations` VALUES (68,'2025_09_29_170912_add_used_at_expires_at_to_tickets_table',1);
INSERT INTO `migrations` VALUES (69,'2025_09_29_172114_create_queue_monitor_table',1);
INSERT INTO `migrations` VALUES (70,'2025_09_29_200000_create_ticket_audit_logs_table',1);
INSERT INTO `migrations` VALUES (71,'2025_09_29_210000_create_qr_validations_table',1);
INSERT INTO `migrations` VALUES (72,'2025_09_29_214724_add_performance_indexes_to_tickets_table',1);
INSERT INTO `migrations` VALUES (73,'2025_10_01_185741_update_users_table_for_generic_accounts',1);
INSERT INTO `migrations` VALUES (75,'2025_10_02_100255_add_customer_data_to_orders_table',2);
INSERT INTO `migrations` VALUES (78,'2025_10_03_132354_add_price_indexes_to_seats_table',3);
INSERT INTO `migrations` VALUES (79,'2025_10_06_123322_create_galleries_table',3);
INSERT INTO `migrations` VALUES (80,'2025_10_06_000000_create_payment_transactions_table',4);
INSERT INTO `migrations` VALUES (81,'2025_10_06_164501_create_order_refunds_table',4);
INSERT INTO `migrations` VALUES (82,'2025_10_06_170147_create_stripe_webhook_events_table',4);
INSERT INTO `migrations` VALUES (83,'2025_10_06_170603_add_revolut_fields_to_orders_table',4);
INSERT INTO `migrations` VALUES (84,'2025_10_06_184106_add_ticket_type_fields_to_tickets_table',4);
INSERT INTO `migrations` VALUES (85,'2025_10_06_184117_add_ticket_status_management_to_tickets_table',4);
INSERT INTO `migrations` VALUES (86,'2025_10_06_184142_add_ticket_status_validation_fields_to_tickets_table',4);
INSERT INTO `migrations` VALUES (87,'2025_10_06_184212_add_blocking_fields_to_tickets_table',4);
INSERT INTO `migrations` VALUES (88,'2025_10_06_184243_add_blocked_status_to_seat_reservations',4);
INSERT INTO `migrations` VALUES (89,'2025_10_06_184306_create_bulk_ticket_status_batches_table',4);
INSERT INTO `migrations` VALUES (90,'2025_10_06_184843_create_seat_reassignments_table',4);
INSERT INTO `migrations` VALUES (91,'2025_10_06_190356_add_unique_constraint_to_seat_id',4);
INSERT INTO `migrations` VALUES (92,'2025_10_06_190357_create_seat_transfer_requests_table',5);
INSERT INTO `migrations` VALUES (93,'2025_10_06_194918_add_profile_fields_to_customers_table',5);
INSERT INTO `migrations` VALUES (94,'2025_10_06_212929_add_granular_statuses_to_orders_table',5);
INSERT INTO `migrations` VALUES (95,'2025_10_06_212954_create_order_modifications_table',5);
INSERT INTO `migrations` VALUES (96,'2025_10_06_213007_create_order_status_audit_logs_table',5);
INSERT INTO `migrations` VALUES (97,'2025_10_06_213324_add_cancelled_status_to_seat_reservations_table',5);
INSERT INTO `migrations` VALUES (98,'2025_10_06_213327_add_cancelled_status_to_tickets_table',5);
INSERT INTO `migrations` VALUES (99,'2025_10_06_224236_create_payment_audit_logs_table',6);
INSERT INTO `migrations` VALUES (100,'2025_10_07_143833_add_stripe_fields_to_orders_table',7);
INSERT INTO `migrations` VALUES (101,'2025_10_07_144937_create_webhook_events_table',8);
INSERT INTO `migrations` VALUES (102,'2025_10_08_121909_create_order_line_items_table',9);
INSERT INTO `migrations` VALUES (103,'2025_10_08_135135_add_stripe_customer_id_to_orders_table',10);
INSERT INTO `migrations` VALUES (104,'2025_10_06_224306_create_payment_reconciliations_table',11);
INSERT INTO `migrations` VALUES (105,'2025_10_06_224348_add_gdpr_fields_to_payment_transactions_and_orders',11);
INSERT INTO `migrations` VALUES (106,'2025_10_06_224418_create_gdpr_audit_logs_table',11);
INSERT INTO `migrations` VALUES (107,'2025_10_08_152651_add_payment_mode_to_orders',12);
INSERT INTO `migrations` VALUES (108,'2025_10_08_152751_add_cash_and_comp_gateways_to_payment_transactions',12);
INSERT INTO `migrations` VALUES (109,'2025_10_08_155245_create_user_consents_table',13);
INSERT INTO `migrations` VALUES (111,'2025_10_09_133231_add_performance_indexes_to_seat_reservations',14);
INSERT INTO `migrations` VALUES (112,'2025_10_09_172052_create_email_accounts_table',15);
INSERT INTO `migrations` VALUES (113,'2025_10_09_172117_create_email_rate_tracking_table',16);
INSERT INTO `migrations` VALUES (114,'2025_10_09_172119_enhance_email_logs_table',17);
INSERT INTO `migrations` VALUES (115,'2025_10_09_172115_create_email_inbox_table',18);
INSERT INTO `migrations` VALUES (116,'2025_10_09_000000_create_mbs_activity_logs_table',19);
INSERT INTO `migrations` VALUES (117,'2025_10_09_150340_create_order_notes_table',19);
INSERT INTO `migrations` VALUES (118,'2025_10_09_180449_create_manager_overrides_table',20);
INSERT INTO `migrations` VALUES (119,'2025_10_09_200000_create_device_tokens_table',20);
INSERT INTO `migrations` VALUES (120,'2025_10_09_200001_create_fire_marshal_tokens_table',20);
INSERT INTO `migrations` VALUES (121,'2025_10_09_184012_add_pin_to_users_table',21);
INSERT INTO `migrations` VALUES (122,'2025_10_09_172120_create_email_reputation_table',22);
INSERT INTO `migrations` VALUES (123,'2025_10_10_115019_create_newsletter_contacts_table',23);
INSERT INTO `migrations` VALUES (124,'2025_10_10_115023_create_newsletter_campaigns_table',23);
INSERT INTO `migrations` VALUES (125,'2025_10_10_115026_create_newsletter_subscriptions_table',23);
INSERT INTO `migrations` VALUES (126,'2025_10_10_000000_create_chargebacks_table',24);
INSERT INTO `migrations` VALUES (127,'2025_10_11_140242_add_missing_fields_to_chargebacks_table',25);
INSERT INTO `migrations` VALUES (128,'2025_10_11_142240_add_needs_response_status_to_chargebacks',26);
INSERT INTO `migrations` VALUES (129,'2025_10_11_000000_add_suspension_fields_to_users_table',27);
INSERT INTO `migrations` VALUES (130,'2025_10_11_170737_add_missing_fields_to_admins_table',27);
INSERT INTO `migrations` VALUES (131,'2025_10_11_172424_create_admin_permissions_table',27);
INSERT INTO `migrations` VALUES (132,'2025_10_11_175141_add_password_changed_at_to_admins_table',27);
INSERT INTO `migrations` VALUES (133,'2025_10_12_171127_add_new_event_fields_to_events_table',28);
INSERT INTO `migrations` VALUES (134,'2025_10_12_171815_add_seo_and_publishing_fields_to_events_table',28);
INSERT INTO `migrations` VALUES (135,'2025_10_12_175638_create_event_categories_table',29);
INSERT INTO `migrations` VALUES (136,'2025_10_12_183527_add_publishing_status_columns_to_events_table',29);
INSERT INTO `migrations` VALUES (137,'2025_10_13_123422_create_venues_table',30);
INSERT INTO `migrations` VALUES (138,'2025_10_13_125852_add_venue_id_to_events_table',31);
INSERT INTO `migrations` VALUES (139,'2025_10_13_131302_refactor_venue_templates_add_venue_id',32);
INSERT INTO `migrations` VALUES (140,'2025_10_13_132027_create_event_venues_table',32);
INSERT INTO `migrations` VALUES (141,'2025_10_13_142019_populate_event_venues_table',33);
INSERT INTO `migrations` VALUES (142,'2025_10_14_120000_add_missing_columns_to_events_table',34);
INSERT INTO `migrations` VALUES (143,'2025_10_15_000001_add_template_support_to_newsletter_campaigns',34);
INSERT INTO `migrations` VALUES (144,'2018_08_08_100000_create_telescope_entries_table',35);
INSERT INTO `migrations` VALUES (145,'2025_01_21_000001_create_venue_themes_table',35);
INSERT INTO `migrations` VALUES (146,'2025_10_16_000001_add_email_tracking_to_orders',35);
INSERT INTO `migrations` VALUES (147,'2025_10_16_171509_add_fee_tax_settings_to_events_table',35);
INSERT INTO `migrations` VALUES (148,'2025_10_16_173156_create_ticket_verification_codes_table',35);
INSERT INTO `migrations` VALUES (149,'2025_10_16_174631_add_code_type_preferences_to_events_table',35);
INSERT INTO `migrations` VALUES (150,'2025_10_17_124724_add_line_item_id_to_ticket_validations_table',35);
INSERT INTO `migrations` VALUES (151,'2025_10_21_000002_add_payment_intent_id_to_webhook_events',35);
INSERT INTO `migrations` VALUES (152,'2025_10_22_112045_create_cms_files_table',35);
INSERT INTO `migrations` VALUES (153,'2025_10_22_130045_create_account_setup_invitations_table',35);
INSERT INTO `migrations` VALUES (154,'2025_10_23_120718_add_campaign_metadata_to_invitations',35);
INSERT INTO `migrations` VALUES (155,'2025_10_23_120750_create_failed_invitation_attempts_table',35);
INSERT INTO `migrations` VALUES (156,'2025_10_23_120827_create_campaign_audit_logs_table',35);
INSERT INTO `migrations` VALUES (157,'2025_10_23_143224_add_indexes_to_account_setup_invitations',35);
INSERT INTO `migrations` VALUES (158,'2025_10_24_000001_clean_venue_architecture',35);
INSERT INTO `migrations` VALUES (159,'2025_10_24_134926_add_is_published_and_publish_website_to_events_table',35);
INSERT INTO `migrations` VALUES (160,'2025_10_24_185319_add_theme_foreign_keys_to_events_and_venues',35);
INSERT INTO `migrations` VALUES (161,'2025_10_25_142803_fix_seats_seat_id_unique_constraint_per_event',36);
INSERT INTO `migrations` VALUES (162,'2025_10_27_144317_add_unique_session_constraint_to_orders_table',36);
INSERT INTO `migrations` VALUES (163,'2025_10_27_151716_add_payment_started_at_to_seat_reservations_table',36);
INSERT INTO `migrations` VALUES (164,'2025_10_28_000001_add_email_tracking_to_account_setup_invitations',36);
INSERT INTO `migrations` VALUES (165,'2025_10_28_000002_add_email_tracking_to_users',36);
INSERT INTO `migrations` VALUES (166,'2025_10_28_170133_add_admin_reservation_support',36);
INSERT INTO `migrations` VALUES (167,'2025_10_28_170330_create_ownership_transfer_requests_table',36);
INSERT INTO `migrations` VALUES (168,'2025_10_29_114258_add_payment_intent_id_to_seat_reservations_table',36);
INSERT INTO `migrations` VALUES (169,'2025_10_30_153808_create_webhook_events_table',36);
INSERT INTO `migrations` VALUES (170,'2025_10_30_205810_add_revolut_order_id_to_seat_reservations_table',36);
INSERT INTO `migrations` VALUES (171,'2025_10_31_124326_add_revolut_metadata_to_events',36);
INSERT INTO `migrations` VALUES (172,'2025_10_31_124400_add_structured_address_to_venues',36);
INSERT INTO `migrations` VALUES (173,'2025_11_03_131603_create_homepage_sections_table',36);
INSERT INTO `migrations` VALUES (174,'2025_11_03_211512_add_bank_transfer_fields_to_orders_table',36);
INSERT INTO `migrations` VALUES (175,'2025_11_03_214956_add_payment_mode_to_seat_reservations_table',36);
INSERT INTO `migrations` VALUES (176,'2025_11_04_000001_create_price_tiers_table',36);
INSERT INTO `migrations` VALUES (177,'2025_11_04_000002_add_tier_fields_to_seats_table',36);
INSERT INTO `migrations` VALUES (178,'2025_11_04_122714_add_payment_gateway_to_seat_reservations',36);
INSERT INTO `migrations` VALUES (179,'2025_11_04_135939_create_admin_password_resets_table',36);
INSERT INTO `migrations` VALUES (180,'2025_11_04_171047_add_optional_fees_to_reservations_and_orders',36);
INSERT INTO `migrations` VALUES (181,'2025_11_04_172805_create_fee_waiver_audit_log_table',36);
INSERT INTO `migrations` VALUES (182,'2025_11_04_185730_add_fee_config_to_events_table',36);
INSERT INTO `migrations` VALUES (183,'2025_11_05_180148_add_media_support_columns_to_cms_files_table',36);
INSERT INTO `migrations` VALUES (184,'2025_11_06_175934_add_currency_to_events_table',36);
INSERT INTO `migrations` VALUES (185,'2025_11_06_202141_add_currency_to_seat_reservations_table',36);
INSERT INTO `migrations` VALUES (186,'2025_11_08_230228_add_seat_prefix_to_price_tiers',36);
INSERT INTO `migrations` VALUES (187,'2025_11_09_110917_create_artists_table',36);
INSERT INTO `migrations` VALUES (188,'2025_11_09_123657_create_artist_event_table',36);
INSERT INTO `migrations` VALUES (189,'2025_11_09_170618_remove_artists_column_from_events_table',36);
INSERT INTO `migrations` VALUES (190,'2025_11_10_000001_add_map_banner_to_events_table',36);
INSERT INTO `migrations` VALUES (191,'2025_11_10_000001_add_released_at_to_seat_reservations_table',36);
INSERT INTO `migrations` VALUES (192,'2025_11_10_194613_fix_seat_reservations_foreign_key_and_orders_unique_constraint',36);
INSERT INTO `migrations` VALUES (193,'2025_11_10_212140_fix_order_refunds_processed_by_foreign_key',36);
INSERT INTO `migrations` VALUES (194,'2025_11_11_000001_create_coupons_table',36);
INSERT INTO `migrations` VALUES (195,'2025_11_11_000002_create_coupon_usage_table',36);
INSERT INTO `migrations` VALUES (196,'2025_11_11_000003_add_coupon_fields_to_seat_reservations_table',36);
INSERT INTO `migrations` VALUES (197,'2025_11_11_000004_add_coupon_fields_to_orders_table',36);
INSERT INTO `migrations` VALUES (198,'2025_11_11_092259_fix_seat_reservations_admin_user_foreign_key',36);
INSERT INTO `migrations` VALUES (199,'2025_11_11_095845_fix_order_refunds_processed_by_foreign_key',36);
INSERT INTO `migrations` VALUES (200,'2025_11_11_112357_add_notes_to_seat_reservations',36);
INSERT INTO `migrations` VALUES (201,'2025_11_11_113629_add_booking_banner_image_to_events_table',36);
INSERT INTO `migrations` VALUES (202,'2025_11_11_224510_add_is_test_mode_to_events_table',36);
INSERT INTO `migrations` VALUES (203,'2025_11_12_000001_add_composite_indexes_for_performance',36);
INSERT INTO `migrations` VALUES (204,'2025_11_13_115435_add_display_in_legend_to_price_tiers_table',36);
INSERT INTO `migrations` VALUES (205,'2025_11_13_164122_create_booking_access_codes_tables',36);
INSERT INTO `migrations` VALUES (206,'2025_11_14_173205_create_analytics_events_table',36);
INSERT INTO `migrations` VALUES (207,'2025_11_17_104017_create_order_audit_log_table',36);
INSERT INTO `migrations` VALUES (208,'2025_11_17_161632_create_waitlist_submissions_table',36);
INSERT INTO `migrations` VALUES (209,'2025_11_18_124703_add_status_to_waitlist_submissions_table',36);
INSERT INTO `migrations` VALUES (210,'2025_11_18_210000_create_scanner_devices_table',36);
INSERT INTO `migrations` VALUES (211,'2025_11_19_120000_add_idempotency_key_to_ticket_validations',36);
INSERT INTO `migrations` VALUES (212,'2025_11_19_195955_add_pos_fields_to_orders_table',36);
INSERT INTO `migrations` VALUES (213,'2025_11_19_204212_add_deposit_reserve_fields_to_orders_table',36);
INSERT INTO `migrations` VALUES (214,'2025_11_23_183337_create_scanner_zones_table',36);
INSERT INTO `migrations` VALUES (215,'2025_11_23_183340_add_zone_fields_to_scanner_devices_table',36);
INSERT INTO `migrations` VALUES (216,'2025_11_24_141603_add_operator_tracking_to_scanner_devices_table',37);
INSERT INTO `migrations` VALUES (217,'2025_11_24_221130_add_scan_type_to_ticket_validations_table',38);
INSERT INTO `migrations` VALUES (218,'2025_11_25_120511_remove_unique_constraint_from_ticket_validations_validation_code',39);
INSERT INTO `migrations` VALUES (219,'2025_11_27_141016_add_wristband_columns_to_events_table',40);
INSERT INTO `migrations` VALUES (220,'2025_11_27_205027_create_mbs_activity_logs_table',41);
INSERT INTO `migrations` VALUES (221,'2025_11_28_133018_add_legacy_fields_to_artists_table',41);
INSERT INTO `migrations` VALUES (222,'2025_11_28_134911_add_legacy_fields_to_events_table',42);
INSERT INTO `migrations` VALUES (223,'2025_11_28_144506_create_archived_events_table',43);
INSERT INTO `migrations` VALUES (224,'2025_11_28_144528_create_archived_event_artist_table',43);
INSERT INTO `migrations` VALUES (225,'2025_11_28_144546_create_event_images_table',43);
INSERT INTO `migrations` VALUES (226,'2025_11_28_153358_add_role_to_event_images_table',44);
INSERT INTO `migrations` VALUES (227,'2025_11_29_170020_add_is_featured_to_archived_events',45);
INSERT INTO `migrations` VALUES (228,'2025_12_01_165319_add_order_reference_to_orders_table',46);
INSERT INTO `migrations` VALUES (229,'2025_12_03_222456_fix_orders_staff_id_foreign_key_references_admins',47);
INSERT INTO `migrations` VALUES (230,'2025_12_08_110336_add_manual_override_to_ticket_validations',48);
INSERT INTO `migrations` VALUES (231,'2025_12_08_111427_create_reseating_log_table',49);
INSERT INTO `migrations` VALUES (232,'2025_12_08_111443_add_reseating_fields_to_orders_table',50);
INSERT INTO `migrations` VALUES (233,'2025_12_08_112643_add_blocking_fields_to_seats',51);
INSERT INTO `migrations` VALUES (234,'2025_12_08_112646_create_seat_state_log_table',52);
INSERT INTO `migrations` VALUES (235,'2025_12_08_122942_add_unique_constraint_twilio_sid_to_whatsapp_logs',53);
INSERT INTO `migrations` VALUES (236,'2025_12_08_122942_create_whatsapp_logs_table',53);
INSERT INTO `migrations` VALUES (237,'2025_12_08_124142_create_support_conversations_table',54);
INSERT INTO `migrations` VALUES (238,'2025_12_08_124546_create_whatsapp_templates_table',55);
INSERT INTO `migrations` VALUES (239,'2025_12_08_125141_add_version_to_support_conversations_table',56);
INSERT INTO `migrations` VALUES (240,'2025_12_08_125427_create_whatsapp_cost_tracker_table',57);
INSERT INTO `migrations` VALUES (241,'0000_00_00_000000_load_schema_dump',58);
INSERT INTO `migrations` VALUES (242,'2026_01_08_100000_normalize_order_status_values',59);
INSERT INTO `migrations` VALUES (243,'2026_01_08_100001_normalize_payment_method_values',59);
INSERT INTO `migrations` VALUES (244,'2026_01_08_140000_add_currency_to_orders_and_normalize_events',59);
INSERT INTO `migrations` VALUES (245,'2026_01_11_182411_normalize_event_status_values',59);
INSERT INTO `migrations` VALUES (246,'2026_01_13_115548_add_publishing_fields_to_venue_templates',59);
INSERT INTO `migrations` VALUES (247,'2026_01_22_190152_create_notification_preferences_table',60);
INSERT INTO `migrations` VALUES (248,'2026_01_11_183523_add_tax_rate_snapshot_to_orders_table',61);
INSERT INTO `migrations` VALUES (249,'2026_01_23_143000_make_email_logs_body_fields_nullable',62);
INSERT INTO `migrations` VALUES (250,'2026_01_11_184508_add_original_price_at_booking_to_order_line_items_table',63);
INSERT INTO `migrations` VALUES (251,'2026_01_25_120000_create_customer_profiles_table',64);
INSERT INTO `migrations` VALUES (252,'2026_01_25_150000_create_email_delivery_logs_table',64);
INSERT INTO `migrations` VALUES (253,'2026_01_25_170000_create_user_audit_logs_table',64);
INSERT INTO `migrations` VALUES (254,'2026_01_25_190329_add_marketing_preferences_to_users_table',64);
INSERT INTO `migrations` VALUES (255,'2026_01_25_192045_add_soft_deletes_to_users_table',64);
INSERT INTO `migrations` VALUES (256,'2026_01_26_170000_make_phone_nullable_in_users_table',64);
INSERT INTO `migrations` VALUES (257,'2026_01_27_122952_add_venue_fork_data_to_events_table',64);
INSERT INTO `migrations` VALUES (258,'2026_01_27_123528_add_locking_columns_to_venue_templates_table',64);
INSERT INTO `migrations` VALUES (259,'2026_02_28_203621_add_tracking_columns_to_email_logs_table',64);
INSERT INTO `migrations` VALUES (260,'2026_03_02_120035_make_club_id_nullable_on_events_table',64);
INSERT INTO `migrations` VALUES (261,'2026_03_02_134325_update_seat_state_log_action_enum',64);
INSERT INTO `migrations` VALUES (262,'2026_03_03_172529_fix_legacy_schema_constraints_for_decomp',64);
INSERT INTO `migrations` VALUES (263,'2026_03_03_185033_make_non_essential_columns_nullable_for_decomp',64);
INSERT INTO `migrations` VALUES (264,'2026_03_03_215154_relax_remaining_strict_constraints_for_decomp',64);
INSERT INTO `migrations` VALUES (265,'2026_03_11_000001_add_booking_mode_to_events_table',64);
INSERT INTO `migrations` VALUES (266,'2026_03_12_000001_expand_payment_gateway_enum',64);
