<?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('adm_bonuses')) {
            Schema::create('adm_bonuses', function(Blueprint $table) {
                $table->id();
                $table->unsignedBigInteger('character_id');
                $table->string('character_name');
                $table->unsignedBigInteger('system_id');
                $table->string('system_name');
                $table->decimal('system_index', 3, 1);
                $table->decimal('system_adm', 5, 2);
                $table->decimal('bonus_percentage');
                $table->decimal('bonus_amount');
                $table->timestamps();
            });
        }

        if(!Schema::hasTable('adm_bonus_account')) {
            Schema::create('adm_bonus_account', function(Blueprint $table) {
                $table->id();
                $table->unsignedBigInteger('character_id');
                $table->string('character_name');
                $table->unsignedBigInteger('account_number');
                $table->decimal('total_amount', 20, 2);
                $table->decimal('total_paid', 20, 2);
                $table->decimal('balance', 20, 2);
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('adm_bonuses');
    }
};
