<?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_detail', function (Blueprint $table) {
            $table->enum('status', ['active', 'canceled'])->default('active')->after('line_total');
            $table->foreignId('canceled_by')->nullable()->constrained('users')->nullOnDelete()->after('status');
            $table->timestamp('canceled_at')->nullable()->after('canceled_by');
        });
    }

    public function down(): void
    {
        Schema::table('orders_detail', function (Blueprint $table) {
            $table->dropConstrainedForeignId('canceled_by');
            $table->dropColumn(['status', 'canceled_at']);
        });
    }
};
