<?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
    {
        if (Schema::hasTable('transactions')) {
            Schema::table('transactions', function (Blueprint $table) {
                if (!Schema::hasColumn('transactions', 'expired_date')) {
                    $table->string('expired_date', 50)->nullable()->after('comment');
                }
                if (!Schema::hasColumn('transactions', 'sender_types')) {
                    $table->integer('sender_types')->nullable()->after('expired_date');
                }
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (Schema::hasTable('transactions')) {
            Schema::table('transactions', function (Blueprint $table) {
                if (Schema::hasColumn('transactions', 'expired_date')) {
                    $table->dropColumn('expired_date');
                }
                if (Schema::hasColumn('transactions', 'sender_types')) {
                    $table->dropColumn('sender_types');
                }
            });
        }
    }
};
