<?php
/**
 * AddTokenColumnToMembersTableUpgrade.php.
 *
 * @package RewardsWP
 */

namespace Awesomemotive\Rewardswp\Database\Upgrades;

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

use Awesomemotive\Rewardswp\Abstracts\AbstractDatabaseUpgrade;
use Awesomemotive\Rewardswp\Database\Tables\MembersTable;

/**
 * Class AddTokenColumnToMembersTableUpgrade.
 */
class AddTokenColumnToMembersTableUpgrade extends AbstractDatabaseUpgrade {
	/**
	 * Upgrade target version.
	 *
	 * @var string
	 */
	protected string $version = '1.0.1';

	/**
	 * Members table instance.
	 *
	 * @since 1.0.1
	 *
	 * @var MembersTable
	 */
	private MembersTable $table;

	/**
	 * Constructor.
	 *
	 * @since 1.0.1
	 *
	 * @param MembersTable $table Members table instance.
	 */
	public function __construct( MembersTable $table ) {
		$this->table = $table;
	}

	/**
	 * Run the upgrade.
	 *
	 * This will include the 'token' column to the Members table.
	 *
	 * @return void
	 */
	public function up(): void {
		$this->table->create_or_update_table();
	}
}
