<?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('plan_promociones', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('plan_id');
            $table->unsignedTinyInteger('meses');
            $table->decimal('descuento_porcentaje', 5, 2)->default(0);
            $table->boolean('activo')->default(true);
            $table->timestamps();

            $table->unique(['plan_id', 'meses']);
            $table->foreign('plan_id')->references('id')->on('planes')->onDelete('cascade');
        });
    }

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