<?php

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

/**
 * PRC-1143 — konsolide şema: `blocked_domain_patterns` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('blocked_domain_patterns', function (Blueprint $t) {
            $t->id();
            $t->string('pattern', 255);
            $t->enum('match_type', ['exact','prefix','suffix','contains','regex'])->default('contains');
            $t->text('reason')->nullable();
            $t->boolean('is_active')->default(1);
            $t->unsignedBigInteger('created_by')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index('is_active', 'blocked_domain_patterns_is_active_index');
            $t->index('pattern', 'blocked_domain_patterns_pattern_index');
            $t->unique(['pattern', 'match_type'], 'blocked_domain_patterns_pattern_match_type_unique');
        });
    }

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