<?php

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

return new class extends Migration
{
  /**
   * Run the migrations.
   */
  public function up(): void
  {
    Schema::table('users', function (Blueprint $table) {
      //
      $table->string('name')->nullable()->change();
      $table->string('email')->nullable()->change();
      $table->string('phone')->nullable()->after('email');
      $table->string('code', 6)->nullable();
      $table->boolean('validated_code')->default(false)->after('code');
    });
  }

  /**
   * Reverse the migrations.
   */
  public function down(): void
  {
    Schema::table('users', function (Blueprint $table) {
      //
      $table->dropColumn('phone');
      $table->string('name')->nullable(false)->change();
      $table->string('email')->nullable(false)->change();
      $table->dropColumn('code');
      $table->dropColumn('validated_code');
    });
  }
};
