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

            $table->foreignId('proveedor_id')
                ->constrained('proveedors')
                ->cascadeOnDelete();

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

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

            // Envío
            $table->date('fecha_envio');
            $table->integer('cantidad_enviada');

            // Recepción
            $table->date('fecha_recepcion')->nullable();
            $table->integer('cantidad_recibida')->nullable();

            // Control
            $table->integer('perdidas')->default(0);

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

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

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