<?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;
        }

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

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

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