<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('platform_settings', function (Blueprint $table): void {
            if (! Schema::hasColumn('platform_settings', 'type')) {
                $table->string('type', 50)->default('string')->index();
            }

            if (! Schema::hasColumn('platform_settings', 'is_encrypted')) {
                $table->boolean('is_encrypted')->default(false)->index();
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('platform_settings', function (Blueprint $table): void {
            if (Schema::hasColumn('platform_settings', 'is_encrypted')) {
                $table->dropColumn('is_encrypted');
            }

            if (Schema::hasColumn('platform_settings', 'type')) {
                $table->dropColumn('type');
            }
        });
    }
};
