[
  {
    "type": "create_table",
    "description": "Create support_categories table for article categories",
    "database": "kiosk_buykiosk",
    "check_query": "SHOW TABLES LIKE 'support_categories'",
    "sql": "CREATE TABLE `support_categories` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `name` varchar(100) NOT NULL COMMENT 'Category display name',\n  `slug` varchar(100) NOT NULL COMMENT 'URL-friendly identifier',\n  `description` text DEFAULT NULL COMMENT 'Category description',\n  `icon` varchar(50) DEFAULT NULL COMMENT 'Icon class (e.g., fa-book)',\n  `sort_order` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Display order',\n  `parent_id` int(10) unsigned DEFAULT NULL COMMENT 'Parent category for subcategories',\n  `is_active` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT 'Active status',\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  UNIQUE KEY `uk_slug` (`slug`),\n  KEY `idx_parent_id` (`parent_id`),\n  KEY `idx_sort_order` (`sort_order`),\n  KEY `idx_is_active` (`is_active`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Support article categories'"
  },
  {
    "type": "create_table",
    "description": "Create support_articles table for knowledge base articles",
    "database": "kiosk_buykiosk",
    "check_query": "SHOW TABLES LIKE 'support_articles'",
    "sql": "CREATE TABLE `support_articles` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `category_id` int(10) unsigned NOT NULL COMMENT 'FK to support_categories.id',\n  `title` varchar(255) NOT NULL COMMENT 'Article title',\n  `slug` varchar(255) NOT NULL COMMENT 'URL-friendly identifier',\n  `content_md` longtext NOT NULL COMMENT 'Markdown content',\n  `content_html` longtext DEFAULT NULL COMMENT 'Rendered HTML content',\n  `author_id` int(10) unsigned NOT NULL COMMENT 'FK to uf_user.id',\n  `status` enum('draft','published','archived') NOT NULL DEFAULT 'draft' COMMENT 'Publication status',\n  `view_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Global view count',\n  `is_featured` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Featured article flag',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),\n  `published_at` timestamp NULL DEFAULT NULL COMMENT 'Publication date',\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_slug` (`slug`),\n  KEY `idx_category_id` (`category_id`),\n  KEY `idx_status` (`status`),\n  KEY `idx_is_featured` (`is_featured`),\n  KEY `idx_published_at` (`published_at`),\n  FULLTEXT KEY `ft_search` (`title`,`content_md`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Support knowledge base articles'"
  },
  {
    "type": "create_table",
    "description": "Create support_article_versions table for article version history",
    "database": "kiosk_buykiosk",
    "check_query": "SHOW TABLES LIKE 'support_article_versions'",
    "sql": "CREATE TABLE `support_article_versions` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `article_id` int(10) unsigned NOT NULL COMMENT 'FK to support_articles.id',\n  `content_md` longtext NOT NULL COMMENT 'Markdown content snapshot',\n  `content_html` longtext DEFAULT NULL COMMENT 'Rendered HTML snapshot',\n  `editor_id` int(10) unsigned NOT NULL COMMENT 'FK to uf_user.id',\n  `edit_note` varchar(255) DEFAULT NULL COMMENT 'Note about this edit',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_article_id` (`article_id`),\n  KEY `idx_editor_id` (`editor_id`),\n  KEY `idx_created_at` (`created_at`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Article version history'"
  },
  {
    "type": "create_table",
    "description": "Create support_search_log table for search tracking and analytics",
    "database": "kiosk_buykiosk",
    "check_query": "SHOW TABLES LIKE 'support_search_log'",
    "sql": "CREATE TABLE `support_search_log` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `store_id` int(10) unsigned DEFAULT NULL COMMENT 'Optional store tracking',\n  `user_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to uf_user.id',\n  `query` varchar(255) NOT NULL COMMENT 'Search query text',\n  `results_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number of results returned',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_query` (`query`),\n  KEY `idx_results_count` (`results_count`),\n  KEY `idx_created_at` (`created_at`),\n  KEY `idx_store_id` (`store_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Search query tracking for analytics'"
  },
  {
    "type": "create_table",
    "description": "Create support_article_images table for uploaded images",
    "database": "kiosk_buykiosk",
    "check_query": "SHOW TABLES LIKE 'support_article_images'",
    "sql": "CREATE TABLE `support_article_images` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `article_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to support_articles.id (NULL if unattached)',\n  `filename` varchar(255) NOT NULL COMMENT 'Stored filename',\n  `original_filename` varchar(255) NOT NULL COMMENT 'Original upload filename',\n  `file_path` varchar(500) NOT NULL COMMENT 'Full file path',\n  `file_size` int(10) unsigned NOT NULL COMMENT 'File size in bytes',\n  `mime_type` varchar(100) NOT NULL COMMENT 'MIME type',\n  `uploaded_by` int(10) unsigned NOT NULL COMMENT 'FK to uf_user.id',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_article_id` (`article_id`),\n  KEY `idx_uploaded_by` (`uploaded_by`),\n  KEY `idx_created_at` (`created_at`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Article uploaded images'"
  },
  {
    "type": "create_table",
    "description": "Create support_article_views table for per-store view tracking",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'support_article_views'",
    "sql": "CREATE TABLE `support_article_views` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `article_id` int(10) unsigned NOT NULL COMMENT 'FK to kiosk_buykiosk.support_articles.id',\n  `employee_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to employees.id',\n  `viewed_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_article_id` (`article_id`),\n  KEY `idx_viewed_at` (`viewed_at`),\n  KEY `idx_employee_id` (`employee_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Per-store article view tracking'"
  },
  {
    "type": "create_table",
    "description": "Create support_article_reactions table for article reactions",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'support_article_reactions'",
    "sql": "CREATE TABLE `support_article_reactions` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `article_id` int(10) unsigned NOT NULL COMMENT 'FK to kiosk_buykiosk.support_articles.id',\n  `employee_id` int(10) unsigned NOT NULL COMMENT 'FK to employees.id',\n  `reaction_type` enum('like','helpful','heart') NOT NULL COMMENT 'Type of reaction',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `uk_article_employee_reaction` (`article_id`,`employee_id`,`reaction_type`),\n  KEY `idx_article_id` (`article_id`),\n  KEY `idx_employee_id` (`employee_id`),\n  KEY `idx_reaction_type` (`reaction_type`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Article reactions (like, helpful, heart)'"
  },
  {
    "type": "create_table",
    "description": "Create support_article_comments table for article comments",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'support_article_comments'",
    "sql": "CREATE TABLE `support_article_comments` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `article_id` int(10) unsigned NOT NULL COMMENT 'FK to kiosk_buykiosk.support_articles.id',\n  `employee_id` int(10) unsigned NOT NULL COMMENT 'FK to employees.id',\n  `comment` text NOT NULL COMMENT 'Comment text',\n  `is_approved` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT 'Approval status',\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_article_id` (`article_id`),\n  KEY `idx_employee_id` (`employee_id`),\n  KEY `idx_is_approved` (`is_approved`),\n  KEY `idx_created_at` (`created_at`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Article comments from store employees'"
  },
  {
    "type": "create_table",
    "description": "Create support_edit_suggestions table for wiki-style edit suggestions",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'support_edit_suggestions'",
    "sql": "CREATE TABLE `support_edit_suggestions` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `article_id` int(10) unsigned NOT NULL COMMENT 'FK to kiosk_buykiosk.support_articles.id',\n  `employee_id` int(10) unsigned NOT NULL COMMENT 'FK to employees.id (suggester)',\n  `suggested_content_md` longtext NOT NULL COMMENT 'Suggested markdown content',\n  `suggestion_note` text DEFAULT NULL COMMENT 'Note explaining the suggestion',\n  `status` enum('pending','approved','rejected') NOT NULL DEFAULT 'pending' COMMENT 'Review status',\n  `reviewer_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to kiosk_buykiosk.uf_user.id',\n  `reviewer_note` text DEFAULT NULL COMMENT 'Note from reviewer',\n  `reviewed_at` timestamp NULL DEFAULT NULL COMMENT 'When reviewed',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  PRIMARY KEY (`id`),\n  KEY `idx_article_id` (`article_id`),\n  KEY `idx_status` (`status`),\n  KEY `idx_employee_id` (`employee_id`),\n  KEY `idx_reviewer_id` (`reviewer_id`),\n  KEY `idx_created_at` (`created_at`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Wiki-style edit suggestions from store employees'"
  }
]
