<?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
    {
        Schema::create('email_settings', function (Blueprint $table) {
            $table->id();
            $table->string('imap_host')->nullable();
            $table->integer('imap_port')->nullable()->default(993);
            $table->string('imap_encryption')->nullable()->default('ssl');
            $table->string('imap_username')->nullable();
            $table->string('imap_password')->nullable();
            $table->string('smtp_host')->nullable();
            $table->integer('smtp_port')->nullable()->default(587);
            $table->string('smtp_encryption')->nullable()->default('tls');
            $table->string('smtp_username')->nullable();
            $table->string('smtp_password')->nullable();
            $table->string('email_address')->nullable();
            $table->string('email_name')->nullable();
            $table->string('reply_to')->nullable();
            $table->integer('sync_interval_minutes')->default(5);
            $table->timestamp('last_sync_at')->nullable();
            $table->boolean('is_active')->default(false);
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('email_settings');
    }
};