<?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::create('sales_managers', function (Blueprint $table) {
            $table->id();
            $table->string('member_id', 50)->unique()->comment('로그인 ID');
            $table->string('password', 255)->comment('비밀번호');
            $table->string('name', 100)->comment('성명');
            $table->string('phone', 20)->nullable()->comment('전화번호');
            $table->string('email', 100)->nullable()->comment('이메일');
            $table->foreignId('parent_id')->nullable()->comment('상위 관리자 ID');
            $table->enum('role', ['operator', 'sales_admin', 'manager'])->default('manager')->comment('역할');
            $table->text('remarks')->nullable()->comment('비고');
            $table->boolean('is_active')->default(true)->comment('활성화 여부');
            $table->timestamps();
            $table->softDeletes();

            $table->index('parent_id');
            $table->index('role');
            $table->index('is_active');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('sales_managers');
    }
};
