<?php

declare(strict_types=1);

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_config_values', function (Blueprint $table) {
            $table->id();
            $table->foreignId('option_id')->constrained('plan_config_options')->cascadeOnDelete();
            $table->string('label');
            $table->string('value')->nullable();
            $table->decimal('hourly_price', 10, 4)->default(0);
            $table->decimal('monthly_price', 10, 2)->default(0);
            $table->decimal('quarterly_price', 10, 2)->default(0);
            $table->decimal('semi_annual_price', 10, 2)->default(0);
            $table->decimal('annual_price', 10, 2)->default(0);
            $table->boolean('is_default')->default(false);
            $table->integer('sort_order')->default(0);
            $table->timestamps();

            $table->index(['option_id', 'sort_order']);
        });
    }

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