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

            // Existing unit_price will become purchase_price
            $table->renameColumn(
                'unit_price',
                'purchase_price'
            );

            // Actual customer-specific selling price
            $table->decimal(
                'sale_price',
                10,
                0
            )->after('purchase_price');
        });
    }

    public function down(): void
    {
        Schema::table('order_details', function (Blueprint $table) {

            // Remove sale price
            $table->dropColumn('sale_price');

            // Restore original column name
            $table->renameColumn(
                'purchase_price',
                'unit_price'
            );
        });
    }
};