[
  {
    "type": "create_table",
    "description": "Create storeStatsAggregate table for pre-computed rolling statistics",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'storeStatsAggregate'",
    "sql": "CREATE TABLE `storeStatsAggregate` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `date` date NOT NULL, `avg30_buys` decimal(10,2) DEFAULT 0, `avg30_containers` decimal(10,2) DEFAULT 0, `avg30_new_customers` decimal(10,2) DEFAULT 0, `avg30_process_time` int(10) unsigned DEFAULT 0 COMMENT 'seconds', `avg30_wait_time` int(10) unsigned DEFAULT 0 COMMENT 'seconds', `avg30_sales` decimal(12,2) DEFAULT 0, `survey90_response_count` int(10) unsigned DEFAULT 0, `survey90_avg_step1` decimal(3,2) DEFAULT NULL COMMENT 'greeting', `survey90_avg_step2` decimal(3,2) DEFAULT NULL COMMENT 'wait time', `survey90_avg_step3` decimal(3,2) DEFAULT NULL COMMENT 'buyer knowledge', `survey90_avg_step4` decimal(3,2) DEFAULT NULL COMMENT 'overall satisfaction', `survey90_avg_step6` decimal(3,2) DEFAULT NULL COMMENT 'NPS-style rating 1-6', `survey90_nps_score` decimal(5,2) DEFAULT NULL COMMENT 'Calculated NPS', `wow_buys_change` decimal(6,2) DEFAULT NULL COMMENT 'percent change', `wow_sales_change` decimal(6,2) DEFAULT NULL COMMENT 'percent change', `wow_containers_change` decimal(6,2) DEFAULT NULL COMMENT 'percent change', `computed_at` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `unique_date` (`date`), KEY `idx_date` (`date`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Pre-computed store statistics for mobile API'"
  }
]
