<?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('stock_movement_serials', function (Blueprint $table) {
            $table->id();
            $table->foreignId('stock_movement_id')->constrained('stock_movements')->cascadeOnDelete();
            $table->foreignId('product_serial_id')->constrained('product_serials')->cascadeOnDelete();
            $table->timestamps();

            $table->unique(['stock_movement_id', 'product_serial_id'], 'sms_movement_serial_unique');
        });
    }

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