<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        // PRC-360 — attachment antivirus scan lifecycle. Default 'clean'
        // for pre-existing rows (they were uploaded before scanning existed
        // and have already passed static validation); new client uploads
        // are created as 'pending' explicitly and scanned by ScanAttachmentJob.
        Schema::table('attachments', function (Blueprint $table) {
            $table->enum('scan_status', ['pending', 'clean', 'infected', 'scan_failed'])
                ->default('clean')
                ->after('upload_source');
            $table->text('scan_message')->nullable()->after('scan_status');
        });
    }

    public function down(): void
    {
        Schema::table('attachments', function (Blueprint $table) {
            $table->dropColumn(['scan_status', 'scan_message']);
        });
    }
};
