<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::table('transactions', function (Blueprint $table) {
            // Add columns without position constraints
            $table->unsignedBigInteger('voucher_id')->nullable();
            $table->string('voucher_code', 50)->nullable();
            $table->decimal('original_price', 15, 2)->nullable();
            $table->decimal('discount_amount', 15, 2)->default(0);
            
            $table->index('voucher_id');
            $table->index('voucher_code');
        });
    }

    public function down()
    {
        Schema::table('transactions', function (Blueprint $table) {
            $table->dropColumn(['voucher_id', 'voucher_code', 'original_price', 'discount_amount']);
        });
    }
};