<?php

declare(strict_types=1);

namespace SecurWP\Modules\AuditLog\Migrations;

use SecurWP\Core\Database\Migration;
use SecurWP\Core\Installer;
use SecurWP\Modules\AuditLog\AuditLog;

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

final class AuditLogSchemaV1 implements Migration {

	public function module_key(): string {
		return 'audit_log';
	}

	public function target_version(): int {
		return 1;
	}

	public function is_applied(): bool {
		return AuditLog::is_schema_current();
	}

	public function apply(): bool {
		Installer::ensure_audit_table_schema();
		AuditLog::backfill_missing_categories();
		return true;
	}
}
