<?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('import_rules', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->string('pattern');
            $table->unsignedBigInteger('category_id');
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
            // $table->unique(['pattern', 'category_id'], 'unique_import_rule');
            $table->string('description')->nullable(); // Optional description for the rule
            $table->boolean('is_active')->default(true); // Flag to enable/disable the rule
            $table->string('created_by')->nullable(); // User who created the rule
        });
    }

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