<?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('employee_number_sequences', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id');
            $table->string('prefix', 50)->nullable();
            $table->unsignedTinyInteger('digits')->default(0);
            $table->unsignedBigInteger('last_number')->default(0);
            $table->timestamps();

            $table->unique('company_id');
            $table->index(['company_id', 'prefix']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('employee_number_sequences');
    }
};
