<?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::table('users', function (Blueprint $table) {
            $table->timestamp('email_authentication_at')->nullable()->after('locale');
            $table->text('app_authentication_secret')->nullable()->after('email_authentication_at');
            $table->json('app_authentication_recovery_codes')->nullable()->after('app_authentication_secret');
        });

        Schema::table('super_admins', function (Blueprint $table) {
            $table->timestamp('email_authentication_at')->nullable()->after('is_active');
            $table->text('app_authentication_secret')->nullable()->after('email_authentication_at');
            $table->json('app_authentication_recovery_codes')->nullable()->after('app_authentication_secret');
        });
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn(['email_authentication_at', 'app_authentication_secret', 'app_authentication_recovery_codes']);
        });
        Schema::table('super_admins', function (Blueprint $table) {
            $table->dropColumn(['email_authentication_at', 'app_authentication_secret', 'app_authentication_recovery_codes']);
        });
    }
};
