<?php
/**
 * File Path: includes/migrations/class-mbs-migration-2-5.php
 *
 * MBS_Migration_2_5 — Sprint F-020 — Related products table
 *
 * Create mbs_related_products table for cross-format product relationships.
 *
 * @package MyBookShowroom
 * @since   3.2.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class MBS_Migration_2_5
 *
 * Create mbs_related_products table for cross-format product relationships.
 *
 * @implements MBS_Migration
 */
class MBS_Migration_2_5 implements MBS_Migration { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	/**
	 * {@inheritdoc}
	 *
	 * @return string
	 */
	public function version(): string {
		return '2.5';
	}

	/**
	 * {@inheritdoc}
	 *
	 * Create mbs_related_products table for cross-format product relationships.
	 *
	 * @return void
	 */
	public function up(): void {
		global $wpdb;
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		$charset_collate = $wpdb->get_charset_collate();
		dbDelta( MBS_DB_Schema::related_products( $wpdb->prefix . 'mbs_related_products', $charset_collate ) );
	}
}
