<?php

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

// Google/Gmail (and any future OAuth-based provider) needs more than a
// single credential: a refresh token, the last access token + its expiry,
// and the authenticated account email. Stored as one encrypted JSON blob
// rather than in `settings` (plain JSON) since a refresh token is a
// long-lived credential equivalent to a password.
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('smtp_configs', function (Blueprint $table) {
            $table->text('oauth_token')->nullable()->after('settings');
        });
    }

    public function down(): void
    {
        Schema::table('smtp_configs', function (Blueprint $table) {
            $table->dropColumn('oauth_token');
        });
    }
};
