<?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
    {
        // Pakasir Settings
        Schema::table('pakasir_settings', function (Blueprint $table) {
            $table->boolean('discord_enabled')->default(false)->after('broadcast_channel');
            $table->text('discord_webhook_url')->nullable()->after('discord_enabled');
            $table->text('discord_message')->nullable()->after('discord_webhook_url');
        });

        // Tripay Settings
        Schema::table('tripay_settings', function (Blueprint $table) {
            $table->boolean('discord_enabled')->default(false)->after('broadcast_channel');
            $table->text('discord_webhook_url')->nullable()->after('discord_enabled');
            $table->text('discord_message')->nullable()->after('discord_webhook_url');
        });

        // Duitku Settings
        Schema::table('duitku_settings', function (Blueprint $table) {
            $table->boolean('discord_enabled')->default(false)->after('broadcast_channel');
            $table->text('discord_webhook_url')->nullable()->after('discord_enabled');
            $table->text('discord_message')->nullable()->after('discord_webhook_url');
        });

        // Ipaymu Settings
        Schema::table('ipaymu_settings', function (Blueprint $table) {
            $table->boolean('discord_enabled')->default(false)->after('broadcast_channel');
            $table->text('discord_webhook_url')->nullable()->after('discord_enabled');
            $table->text('discord_message')->nullable()->after('discord_webhook_url');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Pakasir Settings
        Schema::table('pakasir_settings', function (Blueprint $table) {
            $table->dropColumn(['discord_enabled', 'discord_webhook_url', 'discord_message']);
        });

        // Tripay Settings
        Schema::table('tripay_settings', function (Blueprint $table) {
            $table->dropColumn(['discord_enabled', 'discord_webhook_url', 'discord_message']);
        });

        // Duitku Settings
        Schema::table('duitku_settings', function (Blueprint $table) {
            $table->dropColumn(['discord_enabled', 'discord_webhook_url', 'discord_message']);
        });

        // Ipaymu Settings
        Schema::table('ipaymu_settings', function (Blueprint $table) {
            $table->dropColumn(['discord_enabled', 'discord_webhook_url', 'discord_message']);
        });
    }
};
