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

            $table->id();
            $table->unsignedBigInteger('app_order_id');
            $table->string('ProductCode');
            $table->integer('Quantity');
            $table->decimal('SubTotal', 10, 2);
            $table->timestamps();

            // Add foreign key relationships
            $table->foreign('app_order_id')->references('id')->on('app_orders')->onDelete('cascade');
            $table->foreign('ProductCode')->references('ProductCode')->on('products');
        });
    }

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