<?php

namespace UltraguardPro\modules\login_protect\schema;

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

use UltraguardPro\modules\core\AbstractModuleSchema;

class LoginProtectSchema extends AbstractModuleSchema {

    public function get_module_id(): string {
        return 'login_protect';
    }

    public function get_table_map(): array {
        return [
            'login_protect_stats' => \UltraguardPro\modules\login_protect\db\LoginProtectStatsTable::class,
        ];
    }

    public function get_schemas(): array {
        $cs = $this->charset_collate();

        return [
            $this->table( 'ultraguard_login_protect_stats' ) =>
            "CREATE TABLE {$this->table( 'ultraguard_login_protect_stats' )} (
  id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  ip_address varchar(45) NOT NULL DEFAULT '',
  attempted_url varchar(2083) NOT NULL DEFAULT '',
  user_agent varchar(512) DEFAULT '',
  country_code varchar(2) DEFAULT '',
  was_redirected tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_ip_address (ip_address),
  KEY idx_created_at (created_at),
  KEY idx_was_redirected (was_redirected)
) {$cs};",
        ];
    }
}
