<?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('email_settings', function (Blueprint $table) {
            $table->string('smtp_host')->nullable()->after('protocol');
            $table->integer('smtp_port')->default(587)->after('smtp_host');
            $table->string('smtp_encryption')->default('tls')->after('smtp_port'); // tls, ssl, or null
            $table->string('smtp_username')->nullable()->after('smtp_encryption');
            $table->text('smtp_password')->nullable()->after('smtp_username');
            $table->string('smtp_from_name')->nullable()->after('smtp_password');
            $table->string('smtp_from_address')->nullable()->after('smtp_from_name');
            $table->text('smtp_cc')->nullable()->after('smtp_from_address');
            $table->text('smtp_bcc')->nullable()->after('smtp_cc');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('email_settings', function (Blueprint $table) {
            $table->dropColumn([
                'smtp_host',
                'smtp_port', 
                'smtp_encryption',
                'smtp_username',
                'smtp_password',
                'smtp_from_name',
                'smtp_from_address',
                'smtp_cc',
                'smtp_bcc'
            ]);
        });
    }
};
