<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('clientes', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tenant_id')->constrained()->onDelete('cascade');
            $table->string('nombre');
            $table->string('telefono')->nullable();
            $table->string('email')->nullable();
            $table->enum('tipo_identificacion', ['E', 'P', 'X'])->comment('E=Empresa, P=Persona natural, X=Exterior');
            $table->string('razon_social')->nullable();
            $table->string('ruc')->nullable();
            $table->string('ciudad')->nullable();
            $table->string('direccion')->nullable();
            $table->timestamps();

            $table->index(['tenant_id', 'ruc']);
        });
    }

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