<?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('email')->nullable()->change();

            $table->string('username')->unique();
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();

            $table->string('phone')->nullable()->unique();
            $table->timestamp('phone_verified_at')->nullable();

            $table->string('locale')->default('tk');

            $table->boolean('password_must_be_changed')->default(false);

            $table->json('options')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('email')->change();
            $table->dropColumn('username');
            $table->dropColumn('first_name');
            $table->dropColumn('last_name');

            $table->dropColumn('phone');
            $table->dropColumn('phone_verified_at');

            $table->dropColumn('locale');

            $table->dropColumn('password_must_be_changed');

            $table->dropColumn('options');
        });
    }
};
