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

        // Add streamer_code to ipaymu_transactions
        Schema::table('ipaymu_transactions', function (Blueprint $table) {
            $table->string('streamer_code')->nullable()->after('gold_amount');
            $table->index('streamer_code');
        });

        // Add streamer_code to duitku_transactions
        Schema::table('duitku_transactions', function (Blueprint $table) {
            $table->string('streamer_code')->nullable()->after('gold_amount');
            $table->index('streamer_code');
        });
    }

    public function down(): void
    {
        Schema::table('tripay_transactions', function (Blueprint $table) {
            $table->dropIndex(['streamer_code']);
            $table->dropColumn('streamer_code');
        });

        Schema::table('ipaymu_transactions', function (Blueprint $table) {
            $table->dropIndex(['streamer_code']);
            $table->dropColumn('streamer_code');
        });

        Schema::table('duitku_transactions', function (Blueprint $table) {
            $table->dropIndex(['streamer_code']);
            $table->dropColumn('streamer_code');
        });
    }
};
