<?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('proceso_acabados', function (Blueprint $table) {
            $table->id();

            $table->foreignId('orden_produccion_id')
                ->constrained('orden_produccions')
                ->cascadeOnDelete();

            // Proceso
            $table->string('tipo_proceso');

            // Responsable (opcional proveedor)
            $table->foreignId('proveedor_id')
                ->nullable()
                ->constrained('proveedors')
                ->nullOnDelete();

            $table->string('responsable_interno')->nullable();

            // Cantidades
            $table->integer('cantidad_enviada');
            $table->integer('cantidad_recibida')->nullable();

            // Fechas
            $table->date('fecha_envio');
            $table->date('fecha_recepcion')->nullable();

            $table->text('observaciones')->nullable();

            $table->timestamps();
        });
    }

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