<?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('pickings', function (Blueprint $table) {
            $table->id();
            $table->foreignId('programacion_id')->unique()->constrained('programaciones')->cascadeOnDelete();
            $table->foreignId('sucursal_id')->constrained('sucursales')->cascadeOnDelete();
            $table->enum('estado', ['pendiente', 'en_progreso', 'completado'])->default('pendiente');
            $table->unsignedTinyInteger('porcentaje_completado')->default(0);
            $table->timestamps();
 
            $table->index(['sucursal_id', 'estado']);
        });
    }
 
    public function down(): void
    {
        Schema::dropIfExists('pickings');
    }
};
 