<?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('depreciations', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('trading_year_id');
            $table->unsignedBigInteger('vehicle_id');
            $table->decimal('vehicle_old_price', 8, 2);
            $table->integer('vehicle_used_months');
            $table->decimal('vehicle_depreciated_price', 8, 2);
            $table->decimal('vehicle_depreciated_expenses', 8, 2);
            $table->decimal('vehicle_brought_forward', 8, 2);
            $table->string('total_months_text');
            $table->timestamps();

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

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