<?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::create('blocked_domain_patterns', function (Blueprint $table) {
            $table->id();
            $table->string('pattern', 255);
            $table->enum('match_type', ['exact', 'prefix', 'suffix', 'contains', 'regex'])
                ->default('contains');
            $table->text('reason')->nullable();
            $table->boolean('is_active')->default(true);
            $table->unsignedBigInteger('created_by')->nullable();
            $table->timestamps();

            $table->index('pattern');
            $table->index('is_active');
            $table->unique(['pattern', 'match_type']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('blocked_domain_patterns');
    }
};
