<?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('dentists', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tenant_id')->constrained()->restrictOnDelete();
            $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
            $table->string('name', 190);
            $table->string('specialty', 120)->nullable();
            $table->string('photo_path')->nullable();
            $table->char('color', 7)->default('#0EA5E9');
            $table->unsignedSmallInteger('slot_duration_min')->default(30);
            $table->unsignedSmallInteger('buffer_min')->default(0);
            $table->boolean('is_bookable_online')->default(true);
            $table->enum('status', ['active', 'inactive'])->default('active');
            $table->timestamps();
            $table->softDeletes();
            $table->index(['tenant_id', 'status']);
        });
    }

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