<?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
    {
        if (! Schema::hasColumn('order_details', 'progress_status')) {
            Schema::table('order_details', function (Blueprint $table) {
                $table->string('progress_status')->nullable()->index()->after('product_type');
                $table->text('progress_note')->nullable()->after('progress_status');
                $table->timestamp('progress_updated_at')->nullable()->after('progress_note');
            });
        }
    }

    public function down(): void
    {
        if (Schema::hasColumn('order_details', 'progress_status')) {
            Schema::table('order_details', function (Blueprint $table) {
                $table->dropColumn(['progress_status', 'progress_note', 'progress_updated_at']);
            });
        }
    }
};
