<?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('orders', function (Blueprint $table) {
            $table->foreignId('coupon_id')->nullable()->after('discount')->constrained('coupons')->onDelete('set null');
            $table->text('admin_notes')->nullable()->after('notes');
            $table->foreignId('assigned_to')->nullable()->after('admin_notes')->constrained('users')->onDelete('set null');
        });
    }

    public function down(): void
    {
        Schema::table('orders', function (Blueprint $table) {
            $table->dropForeign(['coupon_id']);
            $table->dropForeign(['assigned_to']);
            $table->dropColumn(['coupon_id', 'admin_notes', 'assigned_to']);
        });
    }
};
