<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('settings', function (Blueprint $table) {
            $table->id();
            $table->string('key')->unique();
            $table->text('value')->nullable();
            $table->timestamps();
        });

        DB::table('settings')->insert([
            ['key' => 'min_trade_amount',     'value' => '1',     'created_at' => now(), 'updated_at' => now()],
            ['key' => 'max_trade_amount',     'value' => '10000', 'created_at' => now(), 'updated_at' => now()],
            ['key' => 'default_payout_pct',   'value' => '85',    'created_at' => now(), 'updated_at' => now()],
            ['key' => 'min_expiry_seconds',   'value' => '30',    'created_at' => now(), 'updated_at' => now()],
            ['key' => 'max_expiry_seconds',   'value' => '3600',  'created_at' => now(), 'updated_at' => now()],
            ['key' => 'maintenance_mode',     'value' => '0',     'created_at' => now(), 'updated_at' => now()],
        ]);
    }

    public function down(): void
    {
        Schema::dropIfExists('settings');
    }
};
