<?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::create('guests', function (Blueprint $table): void {
            $table->id();
            $table->string('full_name');
            $table->string('phone', 50)->unique();
            $table->string('email')->nullable()->unique();
            $table->string('language', 5)->default('ru');
            $table->string('password')->nullable();
            $table->unsignedTinyInteger('discount_percent')->default(0);
            $table->string('discount_code', 50)->nullable()->unique();
            $table->string('status', 30)->default('active');
            $table->text('notes')->nullable();
            $table->unsignedTinyInteger('admin_rating')->nullable();
            $table->string('documents_folder')->nullable();
            $table->boolean('privacy_consent')->default(true);
            $table->timestamps();

            $table->index(['status', 'created_at']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('guests');
    }
};
