<?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('investment_settings', function (Blueprint $table): void {
            $table->decimal('referral_direct_earning_limit', 12, 2)
                ->nullable()
                ->after('referral_indirect_percent');
            $table->decimal('referral_indirect_earning_limit', 12, 2)
                ->nullable()
                ->after('referral_direct_earning_limit');
        });

        Schema::table('investment_settings', function (Blueprint $table): void {
            $table->dropColumn([
                'referral_level_1_payout_enabled',
                'referral_level_2_payout_enabled',
            ]);
        });
    }

    public function down(): void
    {
        Schema::table('investment_settings', function (Blueprint $table): void {
            $table->boolean('referral_level_1_payout_enabled')->default(true)->after('referral_indirect_percent');
            $table->boolean('referral_level_2_payout_enabled')->default(true)->after('referral_level_1_payout_enabled');
        });

        Schema::table('investment_settings', function (Blueprint $table): void {
            $table->dropColumn([
                'referral_direct_earning_limit',
                'referral_indirect_earning_limit',
            ]);
        });
    }
};
