<?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::hasTable('orders') && ! Schema::hasColumn('orders', 'delivery_service_name')) {
            Schema::table('orders', function (Blueprint $table) {
                $table->string('delivery_service_name', 50)->nullable()->after('delivery_man_id');
            });
        }
    }

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