<?php
/**
 * File Path: includes/migrations/class-mbs-migration-4-2.php
 *
 * MBS_Migration_4_2 -- Schema 4.2 -- INSIGHTS-1
 *
 * Creates mbs_buy_link_clicks table for buy-link click tracking.
 * No user_id or full IP stored -- only referrer_host (privacy-safe).
 *
 * @package MyBookShowroom
 * @since   4.2.0
 */

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

/**
 * Class MBS_Migration_4_2
 *
 * @implements MBS_Migration
 */
class MBS_Migration_4_2 implements MBS_Migration { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	public function version(): string {
		return '4.2';
	}

	public function up(): void {
		global $wpdb;
		$charset_collate = $wpdb->get_charset_collate();
		$table           = $wpdb->prefix . 'mbs_buy_link_clicks';

		$sql = MBS_DB_Schema::buy_link_clicks( $table, $charset_collate );
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		dbDelta( $sql );
	}
}
