<?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
    {
        // Add character_id to tripay_transactions
        Schema::table('tripay_transactions', function (Blueprint $table) {
            $table->unsignedBigInteger('character_id')->nullable()->after('user_id');
        });

        // Add character_id to duitku_transactions
        Schema::table('duitku_transactions', function (Blueprint $table) {
            $table->unsignedBigInteger('character_id')->nullable()->after('user_id');
        });

        // Add character_id to ipaymu_transactions
        Schema::table('ipaymu_transactions', function (Blueprint $table) {
            $table->unsignedBigInteger('character_id')->nullable()->after('user_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Remove character_id from tripay_transactions
        Schema::table('tripay_transactions', function (Blueprint $table) {
            $table->dropColumn('character_id');
        });

        // Remove character_id from duitku_transactions
        Schema::table('duitku_transactions', function (Blueprint $table) {
            $table->dropColumn('character_id');
        });

        // Remove character_id from ipaymu_transactions
        Schema::table('ipaymu_transactions', function (Blueprint $table) {
            $table->dropColumn('character_id');
        });
    }
};
