<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->boolean('is_activated')->default(true)->after('email');
            $table->string('activation_token', 64)->nullable()->after('is_activated');
            $table->timestamp('activation_sent_at')->nullable()->after('activation_token');
        });

        // Set all existing users as activated
        DB::table('users')->update(['is_activated' => true]);
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn(['is_activated', 'activation_token', 'activation_sent_at']);
        });
    }
};
