<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('blacklist', function (Blueprint $table) {
            $table->id();
            $table->foreignId('customer_id')->constrained()->onDelete('cascade');
            $table->enum('reason', ['financial', 'violations', 'fraud', 'dangerous_driving', 'non_payment', 'administrative'])->default('administrative');
            $table->text('description');
            $table->dateTime('blacklisted_from');
            $table->dateTime('blacklisted_until')->nullable();
            $table->enum('status', ['active', 'suspended', 'lifted'])->default('active');
            $table->text('evidence')->nullable();
            $table->text('notes')->nullable();
            $table->foreignId('blacklisted_by')->constrained('users')->onDelete('restrict');
            $table->foreignId('lifted_by')->nullable()->constrained('users')->onDelete('set null');
            $table->dateTime('lifted_at')->nullable();
            $table->text('lift_reason')->nullable();
            $table->timestamps();
            $table->index('customer_id');
            $table->index('status');
            $table->index('blacklisted_from');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('blacklist');
    }
};
