<?php

declare(strict_types=1);

namespace SiteFort\Modules\AuditLog\Migrations;

use SiteFort\Core\Database\Migration;
use SiteFort\Core\Installer;
use SiteFort\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;
	}
}
