<?php

namespace AC_SYNC\Includes\Classes\Sql\Version {
    if (!defined('ABSPATH'))
        exit; // Exit if accessed directly

    class Action_Wear_Sql_Version_1_0_8 extends Action_Wear_Sql_Version_Abstract implements Action_Wear_Sql_Version_Interface
    {

        public static function versioningScript()
        {
            global $wpdb;

            // Add index on actionwear_images.sku for faster lookups
            $images_table = $wpdb->prefix . 'actionwear_images';
            $index_exists = $wpdb->get_results("SHOW INDEX FROM $images_table WHERE Key_name = 'idx_images_sku'");
            if (empty($index_exists)) {
                $wpdb->query("CREATE UNIQUE INDEX idx_images_sku ON $images_table (sku)");
            }

            // Add index on actionwear_products.brand_name for brand-based queries
            $products_table = $wpdb->prefix . 'actionwear_products';
            $brand_index_exists = $wpdb->get_results("SHOW INDEX FROM $products_table WHERE Key_name = 'idx_products_brand'");
            if (empty($brand_index_exists)) {
                $wpdb->query("CREATE INDEX idx_products_brand ON $products_table (brand_name)");
            }
        }
    }
}
