<?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
    {
        Schema::table('digital_forms', function (Blueprint $table) {
            if (! Schema::hasColumn('digital_forms', 'evidence_paths')) {
                $table->json('evidence_paths')->nullable()->after('general_note');
            }

            if (! Schema::hasColumn('digital_forms', 'delete_after')) {
                $table->timestamp('delete_after')->nullable()->index()->after('signature_path');
            }
        });
    }

    public function down(): void
    {
        Schema::table('digital_forms', function (Blueprint $table) {
            if (Schema::hasColumn('digital_forms', 'evidence_paths')) {
                $table->dropColumn('evidence_paths');
            }

            if (Schema::hasColumn('digital_forms', 'delete_after')) {
                $table->dropColumn('delete_after');
            }
        });
    }
};
