<?php

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

// NOTA: Breeze ya crea la tabla users base.
// Esta migración agrega los campos extra que necesita GastroGe.

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('dni', 8)->nullable()->unique()->after('email');
            $table->string('telefono', 20)->nullable()->after('dni');
            $table->boolean('activo')->default(true)->after('telefono');
            $table->foreignId('sucursal_default_id')
                  ->nullable()
                  ->after('activo')
                  ->constrained('sucursales')
                  ->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropForeign(['sucursal_default_id']);
            $table->dropColumn(['dni', 'telefono', 'activo', 'sucursal_default_id']);
        });
    }
};