<?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('departments', function (Blueprint $table) {
            $table->id();
            $table->foreignId('store_id')->constrained()->comment('所属门店');
            $table->unsignedBigInteger('parent_id')->default(0)->comment('上级部门');
            $table->string('name', 50)->comment('部门名称');
            $table->integer('sort')->default(0);
            $table->tinyInteger('status')->default(1)->comment('1启用 0停用');
            $table->timestamps();

            $table->index('store_id');
        });
    }

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