<?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('payment_receipts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('payment_id')->constrained('payments')->onDelete('cascade');
            $table->string('receipt_number')->unique();
            $table->timestamp('issued_date');
            $table->string('pdf_url')->nullable(); // stored copy of the receipt
            $table->timestamps();
            
            // Indexes for better performance
            $table->index(['payment_id']);
            $table->index(['receipt_number']);
            $table->index(['issued_date']);
        });
    }

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