<?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::table('order_items', function (Blueprint $table) {
            if (!Schema::hasColumn('order_items', 'product_name')) { $table->string('product_name')->nullable(); }
            if (!Schema::hasColumn('order_items', 'price')) { $table->decimal('price', 15, 2)->nullable(); }
            if (!Schema::hasColumn('order_items', 'subtotal')) { $table->decimal('subtotal', 15, 2)->nullable(); }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('order_items', function (Blueprint $table) {
            $table->dropColumn(['product_name', 'price', 'subtotal']);
        });
    }
};


