<?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('profesionales', function (Blueprint $table) {
            $table->id();
            $table->timestamps();

            $table->foreignid('profesion_id')
                  ->constrained('profesiones');

            $table->string('matricula');
            $table->string('correo');
            $table->string('dni');

            $table->foreignId('credencialprofesional_id')
                  ->constrained('credencialesprofesionales');

            $table->foreignId('persona_id')
                  ->constrained('personas');

            $table->foreignId('baja_id')
                ->default(1)
                ->constrained('bajas');

            $table->unique(['profesion_id', 'matricula']);      
        });
    }

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