<?php

/**
 * Fired during plugin deactivation
 *
 * @link       https://wpiron.com
 * @since      1.0.0
 *
 * @package    iron-security
 * @subpackage iron-security/includes
 */

/**
 * Fired during plugin deactivation.
 *
 * This class defines all code necessary to run during the plugin's deactivation.
 *
 * @since      1.0.0
 * @package    iron-security
 * @subpackage iron-security/includes
 * @author     WPIron <info@wpiron.com>
 */
class iron_securi_2fa {

	/**
	 * Short Description. (use period)
	 *
	 * Long Description.
	 *
	 * @since    1.0.0
	 */
	public static function activate() {
		global $wpdb;  // Access the global WordPress database object

		// SQL to create a table for user 2FA secrets
		$table_name = $wpdb->prefix . 'wpiron_user_2fa_secrets'; // Prefix ensures unique table name
		$charset_collate = $wpdb->get_charset_collate();

		$sql = "CREATE TABLE $table_name (
        id mediumint(9) NOT NULL AUTO_INCREMENT,
        user_id bigint(20) NOT NULL,
        secret_key varchar(255) NOT NULL,
        PRIMARY KEY  (id),
        UNIQUE KEY user_id (user_id)
    ) $charset_collate;";

		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
		dbDelta($sql);
	}

}
