<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $this->down();
        Schema::create('secciones_validaciones', function (Blueprint $table) {
            $table->id();
            $table->string('campo');
            $table->string('validacion');
            $table->unsignedBigInteger('tipo_seccion_id');
            $table->foreign('tipo_seccion_id')->references('id')
                ->on('tipos_secciones')->onDelete('cascade');
            $table->unique(['campo', 'tipo_seccion_id'], 'unique_index');
            $table->boolean('estado')->default(true);
            $table->timestamps();
        });
    }

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