<?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('srp_ships')) {
            Schema::create('srp_ships', function (Blueprint $table) {
                $table->increments('id');
                $table->string('character_id')->default('N/A');
                $table->string('character_name');
                $table->string('fleeet_commander_id')->default('0');
                $table->string('fleet_commander_name');
                $table->string('zkillboard');
                $table->string('ship_type');
                $table->enum('fleet_type', [
                    'Home Defense',
                    'Fun Fleet',
                    'ADM Fleet',
                    'Casuals',
                    'Strat Op',
                    'CTA',
                    'None',
                ]);
                $table->decimal('loss_value', 20, 2);
                $table->enum('approval', [
                    'Under Review',
                    'Approved',
                    'Denied',
                ]);
                $table->decimal('paid_value', 20, 2);
                $table->text('notes')->nullable();
                $table->string('paid_by_id')->nullable();
                $table->string('paid_by_name')->nullable();
            });
        }

        if(!Schema::hasTable('srp_ship_types')) {
            Schema::create('srp_ship_types', function (Blueprint $table) {
                $table->increments('id');
                $table->string('code');
                $table->string('description');
            });
        }

        if(!Schema::hasTable('srp_payouts')) {
            Schema::create('srp_payouts', function (Blueprint $table) {
                $table->increments('id');
                $table->string('code');
                $table->decimal('payout', 5, 2);
            });
        }
    }

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