<?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
    {
        // Update matches table to replace 'amount' with 'ordinary_amount' and 'vip_amount'
        Schema::table('matches', function (Blueprint $table) {
            $table->decimal('ordinary_amount', 8, 2)->default(0.00)->after('stadium');
            $table->decimal('vip_amount', 8, 2)->default(0.00)->after('ordinary_amount');
            $table->dropColumn('amount');
        });

        // Add category to tickets table
        Schema::table('tickets', function (Blueprint $table) {
            $table->enum('category', ['ordinary', 'vip'])->default('ordinary')->after('match_id');
        });
    }

    public function down(): void
    {
        // Revert changes to matches table
        Schema::table('matches', function (Blueprint $table) {
            $table->decimal('amount', 8, 2)->default(0.00)->after('stadium');
            $table->dropColumn(['ordinary_amount', 'vip_amount']);
        });

        // Remove category from tickets table
        Schema::table('tickets', function (Blueprint $table) {
            $table->dropColumn('category');
        });
    }
};