<?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('capital_allowances', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('vehicle_id');
            $table->unsignedBigInteger('trading_year_id');
            $table->decimal('capital_allowances', 10, 2);
            $table->decimal('capital_allowances_per_month', 10, 2);
            $table->integer('vehicle_usage_months');
            $table->decimal('next_year_vehicle_value', 10, 2);
            $table->decimal('co2_limit', 5, 2);
            $table->string('is_pre_april_2021');
            $table->string('pool_rate_applied');
            $table->decimal('capital_allowances_rate', 5, 2);
            $table->timestamps();

            $table->foreign('vehicle_id')->references('id')->on('vehicles')->onDelete('cascade');
            $table->foreign('trading_year_id')->references('id')->on('trading_years')->onDelete('cascade');
        });
    }

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