[
  {
    "type": "create_table",
    "description": "Create replenishmentTracking table - tracks last replenishment date per category for hybrid time window calculation",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'replenishmentTracking'",
    "sql": "CREATE TABLE `replenishmentTracking` (\n  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n  `subcategoryCode` VARCHAR(10) NOT NULL COMMENT 'POS subcategory code',\n  `lastReplenishmentDate` TIMESTAMP NOT NULL COMMENT 'When category was last replenished',\n  `resetType` ENUM('task_completion', 'manual_category', 'manual_all') NOT NULL COMMENT 'How the reset was triggered',\n  `resetBy` INT UNSIGNED NULL COMMENT 'FK to kiosk_users.users.id (no FK constraint in store DB)',\n  `createdAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  INDEX `idx_subcategoryCode` (`subcategoryCode`),\n  INDEX `idx_lastReplenishmentDate` (`lastReplenishmentDate`),\n  INDEX `idx_resetBy` (`resetBy`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Tracks replenishment dates per category for hybrid time window'"
  },
  {
    "type": "create_table",
    "description": "Create replenishmentCategorySettings table - category-level threshold overrides",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'replenishmentCategorySettings'",
    "sql": "CREATE TABLE `replenishmentCategorySettings` (\n  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n  `subcategoryCode` VARCHAR(10) NOT NULL COMMENT 'POS subcategory code',\n  `thresholdAdequate` DECIMAL(5,2) NULL COMMENT 'Override store default; NULL means use store default',\n  `thresholdMonitor` DECIMAL(5,2) NULL COMMENT 'Override store default; NULL means use store default',\n  `thresholdUrgent` DECIMAL(5,2) NULL COMMENT 'Override store default; NULL means use store default',\n  `thresholdCritical` DECIMAL(5,2) NULL COMMENT 'Override store default; NULL means use store default',\n  `isActive` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Can disable category from reports',\n  `notes` TEXT NULL COMMENT 'Admin notes about this category',\n  `createdAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  `updatedAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_subcategoryCode` (`subcategoryCode`),\n  INDEX `idx_isActive` (`isActive`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Category-level threshold overrides for replenishment'"
  }
]
