<?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('product_contributions', function (Blueprint $table) {
            $table->id();
            //$table->foreignId('product_id')->constrained('products', 'product_id')->onDelete('cascade');
            $table->unsignedBigInteger('product_id'); // fix: explicit FK
            $table->foreign('product_id')
                ->references('product_id')
                ->on('products')
                ->onDelete('cascade');
            $table->string('age_group_label', 50)->comment('e.g. 2 months-17 years');
            $table->integer('age_min_months')->comment('Minimum age in months');
            $table->integer('age_max_months')->comment('Maximum age in months, 9999 for open-ended');
            $table->decimal('contribution_pkr', 12, 2)->comment('Annual contribution in PKR');
            $table->timestamps();
        });
    }

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