<?php

namespace UltraguardPro\modules\compliance_reports\schema;

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

use UltraguardPro\modules\core\AbstractModuleSchema;

class ComplianceReportsSchema extends AbstractModuleSchema {

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

    public function get_table_map(): array {
        return [
            'generated_reports' => \UltraguardPro\modules\compliance_reports\db\GeneratedReportsTable::class,
        ];
    }

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

        return [
            $this->table( 'ultraguard_generated_reports' ) =>
            "CREATE TABLE {$this->table('ultraguard_generated_reports')} (
  id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  report_type varchar(50) NOT NULL,
  report_title varchar(255) NOT NULL,
  date_range_from date NOT NULL,
  date_range_to date NOT NULL,
  format varchar(10) DEFAULT 'html',
  file_path text DEFAULT NULL,
  file_size bigint(20) UNSIGNED DEFAULT 0,
  generated_by bigint(20) UNSIGNED DEFAULT NULL,
  status varchar(20) DEFAULT 'pending',
  sections text DEFAULT NULL,
  error_message text DEFAULT NULL,
  created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_report_type (report_type),
  KEY idx_created_at (created_at)
) {$cs};",
        ];
    }
}
