<?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('deal_product_lines',function(Blueprint $table){
   $table->string('discount_approval_status')->default('not_required')->index();
   $table->decimal('requested_discount',8,2)->nullable();
  });
  Schema::create('deal_discount_approvals',function(Blueprint $table){
   $table->id();$table->foreignId('business_id')->index();$table->foreignId('deal_id')->index();
   $table->foreignId('deal_product_line_id')->index();$table->foreignId('requested_by')->nullable()->index();
   $table->foreignId('decided_by')->nullable()->index();$table->decimal('requested_discount',8,2);
   $table->decimal('allowed_discount',8,2);$table->string('status')->default('pending')->index();
   $table->text('reason')->nullable();$table->text('decision_note')->nullable();$table->timestamp('decided_at')->nullable();$table->timestamps();
  });
 }
 public function down(): void {
  Schema::dropIfExists('deal_discount_approvals');
  Schema::table('deal_product_lines',fn(Blueprint $table)=>$table->dropColumn(['discount_approval_status','requested_discount']));
 }
};
