<?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::create('program_qr_codes', function (Blueprint $table) {
            $table->id();
            $table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
            $table->string('token', 64)->unique();
            $table->string('qr_image_path', 500)->nullable();
            $table->boolean('is_active')->default(true);
            $table->timestamps();

            $table->index('token');
            $table->index('program_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('program_qr_codes');
    }
};
