<?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::table('payroll_salary_components', function (Blueprint $table) {
            $table->string('sub_type', 50)->nullable()->after('type');
            $table->foreignId('expense_account_id')->nullable()->after('sub_type')->constrained('accounts')->nullOnDelete();
            $table->foreignId('liability_account_id')->nullable()->after('expense_account_id')->constrained('accounts')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('payroll_salary_components', function (Blueprint $table) {
            $table->dropConstrainedForeignId('liability_account_id');
            $table->dropConstrainedForeignId('expense_account_id');
            $table->dropColumn('sub_type');
        });
    }
};
