<?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
    {
        if (! Schema::hasTable('matchcobntests')) {
            return;
        }

        if (! Schema::hasColumn('matchcobntests', 'contest_type')) {
            Schema::table('matchcobntests', function (Blueprint $table): void {
                $table->string('contest_type', 20)->default('paid')->after('contesttitile');
            });
        }
    }

    public function down(): void
    {
        if (! Schema::hasTable('matchcobntests') || ! Schema::hasColumn('matchcobntests', 'contest_type')) {
            return;
        }

        Schema::table('matchcobntests', function (Blueprint $table): void {
            $table->dropColumn('contest_type');
        });
    }
};
