<?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('invoices', function (Blueprint $t) {
            $t->unsignedTinyInteger('installment_count')->default(1)->after('gateway_fee');
            $t->decimal('installment_surcharge', 15, 2)->default(0)->after('installment_count');
        });
        Schema::table('transactions', function (Blueprint $t) {
            $t->unsignedTinyInteger('installment_count')->nullable();
            $t->decimal('installment_surcharge', 15, 2)->nullable();
        });
    }

    public function down(): void
    {
        Schema::table('invoices', function (Blueprint $t) {
            $t->dropColumn(['installment_count', 'installment_surcharge']);
        });
        Schema::table('transactions', function (Blueprint $t) {
            $t->dropColumn(['installment_count', 'installment_surcharge']);
        });
    }
};
