<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVendorOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('vendor_orders', function (Blueprint $table) {
            $table->id(); // Primary key
            $table->foreignId('inventory_id') // Foreign key referencing inventory table
                  ->constrained('inventory') 
                  ->onDelete('cascade'); // Cascade delete if inventory item is deleted
            $table->string('vendor_id'); // Could store vendor's identifier (e.g., UUID or ID from vendors table)
            $table->integer('quantity'); // Quantity ordered
            $table->timestamps(); // Adds created_at and updated_at fields
        });
    }

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