-- Ürün listesi / filter.php araması için FULLTEXT dizini (MySQL InnoDB).
-- Idempotent: dizin zaten varsa atlanır.
USE faunamix;

SET @has_ft := (
  SELECT COUNT(*) FROM information_schema.STATISTICS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'products'
    AND INDEX_NAME = 'ft_products_catalog_search'
);
SET @sql_ft := IF(@has_ft = 0,
  'ALTER TABLE products ADD FULLTEXT INDEX ft_products_catalog_search (title, description)',
  'SELECT 1');
PREPARE stmt_ft FROM @sql_ft;
EXECUTE stmt_ft;
DEALLOCATE PREPARE stmt_ft;
