<?php

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

return new class extends Migration {
    public function up()
    {
        Schema::create('site_users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('site_id')->nullable();
            $table->string('first_name', 64);
            $table->string('last_name', 64);
            $table->string('email', 64)->default('');
            $table->string('phone', 15)->default('');
            $table->string('mobile', 15)->default('');
            $table->string('position', 64);
            $table->tinyInteger('authority')->default(0);
            $table->timestamps();

            $table->index('site_id', 'site_users_site_id_foreign');
            $table->index('phone', 'site_users_phone_index');
            $table->index('mobile', 'site_users_mobile_index');
            $table->foreign('site_id')->references('id')->on('sites')->onDelete('set null');
        });
    }

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