<?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('general_settings')) {
            return;
        }

        if (!Schema::hasColumn('general_settings', 'courses_banner')) {
            Schema::table('general_settings', function (Blueprint $table) {
                $table->string('courses_banner', 255)->nullable()->after('reselling_banner');
            });
        }
    }

    public function down(): void
    {
        if (!Schema::hasTable('general_settings')) {
            return;
        }

        if (Schema::hasColumn('general_settings', 'courses_banner')) {
            Schema::table('general_settings', function (Blueprint $table) {
                $table->dropColumn('courses_banner');
            });
        }
    }
};
