<?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::table('casos', function (Blueprint $table) {
            $table->enum('tipo_contrato', ['E', 'P', 'X'])->default('E')->after('tenant_id');
            $table->string('afectado_nombre')->nullable()->after('cobertura');
            $table->string('afectado_email')->nullable()->after('afectado_nombre');
            $table->string('afectado_telefono')->nullable()->after('afectado_email');
            $table->decimal('valor_kilometraje', 10, 2)->nullable()->after('tarifa_kilometro');
            $table->decimal('tarifa_ajuste', 10, 2)->nullable()->after('valor_kilometraje');
        });

        Schema::table('vehiculos', function (Blueprint $table) {
            $table->boolean('has_extras')->default(false)->after('valor_asegurado');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('casos', function (Blueprint $table) {
            $table->dropColumn(['tipo_contrato', 'afectado_nombre', 'afectado_email', 'afectado_telefono', 'valor_kilometraje', 'tarifa_ajuste']);
        });

        Schema::table('vehiculos', function (Blueprint $table) {
            $table->dropColumn('has_extras');
        });
    }
};
