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

            $table->foreignId('credencialcliente_id')
                  ->constrained('credencialesclientes')
                  ->onDelete('cascade');

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

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

            $table->unique(['dni','correo']);
        });
    }

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