<?php

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

return new class extends Migration
{
    /**
     * Grandfathers in every account that registered before email verification
     * was actively enforced — without this, turning on MustVerifyEmail would
     * lock out every existing user (including whoever administers the app).
     */
    public function up(): void
    {
        DB::table('users')
            ->whereNull('email_verified_at')
            ->update(['email_verified_at' => now()]);
    }

    public function down(): void
    {
        // Intentionally a no-op — do not un-verify accounts on rollback.
    }
};
