[
  {
    "type": "create_table",
    "description": "Create storeMetricsDaily table for cross-store analytics aggregation",
    "database": "kiosk_buykiosk",
    "check_query": "SHOW TABLES LIKE 'storeMetricsDaily'",
    "sql": "CREATE TABLE `storeMetricsDaily` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `typeNum` varchar(10) NOT NULL COMMENT 'Store identifier', `date` date NOT NULL COMMENT 'Date of metrics', `storeType` varchar(50) DEFAULT NULL COMMENT 'Store concept/type for peer grouping', `buyCount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Total buys for the day', `avgWaitMinutes` decimal(10,2) DEFAULT NULL COMMENT 'Average wait time in minutes', `medianWaitMinutes` decimal(10,2) DEFAULT NULL COMMENT 'Median wait time in minutes', `maxWaitMinutes` decimal(10,2) DEFAULT NULL COMMENT 'Maximum wait time in minutes', `totalRevenue` decimal(12,2) NOT NULL DEFAULT 0 COMMENT 'Total purchase revenue', `avgPurchaseAmount` decimal(10,2) DEFAULT NULL COMMENT 'Average purchase amount', `uniqueCustomers` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Unique customers served', `repeatCustomers` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Repeat customers (more than 1 buy)', `npsScore` decimal(4,2) DEFAULT NULL COMMENT 'Average NPS score for the day', `npsResponses` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number of NPS responses', `createdAt` datetime NOT NULL DEFAULT current_timestamp(), `updatedAt` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `idx_typeNum_date` (`typeNum`, `date`), KEY `idx_date` (`date`), KEY `idx_storeType_date` (`storeType`, `date`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Daily store metrics for peer comparison analytics'"
  }
]
