<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * The SaaS pricing tiers a company subscribes to — entirely separate
     * from the existing `plans` table, which prices course bundles for
     * students inside a company. Managed only from the SaaS control panel.
     */
    public function up(): void
    {
        Schema::create('subscription_plans', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug')->unique();
            $table->decimal('price', 10, 2)->default(0);
            $table->enum('billing_interval', ['monthly', 'yearly'])->default('monthly');
            $table->unsignedInteger('user_limit')->nullable(); // null = unlimited
            $table->boolean('custom_domain_allowed')->default(true);
            $table->enum('status', ['active', 'archived'])->default('active');
            $table->timestamps();
        });
    }

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