<?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('travel_policies', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('corporate_account_id');
            $table->string('name');
            $table->text('description')->nullable();
            $table->decimal('max_ride_cost', 10, 2)->nullable();
            $table->json('allowed_ride_types')->nullable();
            $table->json('blackout_dates')->nullable();
            $table->boolean('pre_approval_required')->default(false);
            $table->decimal('approval_required_above_amount', 10, 2)->nullable();
            $table->json('restricted_areas')->nullable();
            $table->timestamps();
            
            $table->foreign('corporate_account_id')->references('id')->on('corporate_accounts')->onDelete('cascade');
            $table->index('corporate_account_id');
        });
    }

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