<?php

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

    class Action_Wear_Sql_Version_1_0_6 extends Action_Wear_Sql_Version_Abstract implements Action_Wear_Sql_Version_Interface
    {

        public static function versioningScript()
        {
            global $wpdb;

            $queries = [
                // Composite index for frequent filter on wc_to_create + wc_created
                "ALTER TABLE {$wpdb->prefix}actionwear_products ADD INDEX idx_wc_status (`wc_to_create`, `wc_created`)",
                // Index for product-category lookup by product
                "ALTER TABLE {$wpdb->prefix}actionwear_categories_product ADD INDEX idx_id_product (`id_product`)",
                // Index for product-category lookup by category
                "ALTER TABLE {$wpdb->prefix}actionwear_categories_product ADD INDEX idx_id_category (`id_category`)",
                // Index for image lookup by SKU
                "ALTER TABLE {$wpdb->prefix}actionwear_images ADD INDEX idx_sku (`sku`)",
            ];

            foreach ($queries as $query) {
                $wpdb->query($query);
            }
        }
    }
}
