<?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('financial_data', function (Blueprint $table) {
            $table->id();
            $table->foreignId('analysis_result_id')->nullable()->constrained('analysis_results')->onDelete('cascade');
            $table->foreignId('company_id')->nullable()->constrained()->onDelete('cascade');
            $table->decimal('aset_lancar', 15, 2);
            $table->decimal('aset_tetap', 15, 2);
            $table->decimal('utang_lancar', 15, 2);
            $table->decimal('utang_jangka_panjang', 15, 2);
            $table->decimal('pendapatan', 15, 2);
            $table->decimal('biaya_operasional', 15, 2);
            $table->decimal('prive', 15, 2);
            $table->decimal('total_aset', 15, 2)->nullable();
            $table->decimal('total_utang', 15, 2)->nullable();
            $table->decimal('nilai_buku_ekuitas', 15, 2)->nullable();
            $table->decimal('laba_sebelum_pajak', 15, 2)->nullable();
            $table->decimal('laba_ditahan', 15, 2)->nullable();
            $table->timestamps();
        });
    }

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