[
  {
    "type": "create_table",
    "description": "Create bsEvents table for per-store event configuration",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'bsEvents'",
    "sql": "CREATE TABLE `bsEvents` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `templateId` int(10) unsigned DEFAULT NULL COMMENT 'FK to kiosk_buykiosk.bsEventTemplates, NULL for custom events',\n  `name` varchar(100) NOT NULL,\n  `eventType` enum('season','holiday','sale','custom') NOT NULL DEFAULT 'custom',\n  `year` year NOT NULL,\n  `startDate` date NOT NULL,\n  `endDate` date NOT NULL,\n  `buildUpDays` int(10) unsigned NOT NULL DEFAULT 14,\n  `windDownDays` int(10) unsigned NOT NULL DEFAULT 7,\n  `color` varchar(10) DEFAULT NULL,\n  `icon` varchar(50) DEFAULT NULL,\n  `notes` text DEFAULT NULL,\n  `isActive` tinyint(1) unsigned DEFAULT 1,\n  `isRecurring` tinyint(1) unsigned DEFAULT 1,\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_startDate` (`startDate`),\n  KEY `idx_endDate` (`endDate`),\n  KEY `idx_year` (`year`),\n  KEY `idx_isActive` (`isActive`),\n  KEY `idx_eventType` (`eventType`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Store-specific seasonal events configuration'"
  },
  {
    "type": "create_table",
    "description": "Create bsEvent_Categories table to link categories to events",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'bsEvent_Categories'",
    "sql": "CREATE TABLE `bsEvent_Categories` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `eventId` int(10) unsigned NOT NULL,\n  `categoryId` int(10) unsigned NOT NULL COMMENT 'FK to bsCategories.id',\n  `priority` tinyint(3) unsigned DEFAULT 5 COMMENT '1-10 priority rating',\n  `notes` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_event_category` (`eventId`, `categoryId`),\n  KEY `idx_eventId` (`eventId`),\n  KEY `idx_categoryId` (`categoryId`),\n  CONSTRAINT `fk_bsEvent_Categories_eventId` FOREIGN KEY (`eventId`) REFERENCES `bsEvents` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Links categories to seasonal events'"
  },
  {
    "type": "create_table",
    "description": "Create bsEvent_Progress table for event progress tracking",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'bsEvent_Progress'",
    "sql": "CREATE TABLE `bsEvent_Progress` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `eventId` int(10) unsigned NOT NULL,\n  `phase` enum('upcoming','build_up','active','wind_down','completed') NOT NULL,\n  `binsPulled` int(10) unsigned DEFAULT 0 COMMENT 'Bins pulled from backstock',\n  `binsOnFloor` int(10) unsigned DEFAULT 0 COMMENT 'Bins currently on sales floor',\n  `binsStored` int(10) unsigned DEFAULT 0 COMMENT 'Bins returned to backstock',\n  `lastUpdated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_eventId` (`eventId`),\n  KEY `idx_phase` (`phase`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Tracks progress of seasonal events'"
  },
  {
    "type": "create_table",
    "description": "Create bsEvent_Alerts table for event notifications",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'bsEvent_Alerts'",
    "sql": "CREATE TABLE `bsEvent_Alerts` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `eventId` int(10) unsigned NOT NULL,\n  `alertType` enum('build_up_starting','build_up_behind','event_starting','event_started','wind_down_starting','wind_down_behind','event_ended') NOT NULL,\n  `message` text NOT NULL,\n  `binCount` int(10) unsigned DEFAULT NULL COMMENT 'Relevant bin count for context',\n  `acknowledged` tinyint(1) unsigned DEFAULT 0,\n  `acknowledgedBy` int(10) unsigned DEFAULT NULL COMMENT 'FK to employees.id',\n  `acknowledgedAt` timestamp NULL DEFAULT NULL,\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_eventId` (`eventId`),\n  KEY `idx_acknowledged_created` (`acknowledged`, `created_at`),\n  KEY `idx_alertType` (`alertType`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Notifications and alerts for seasonal events'"
  }
]
