<?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('plans', function (Blueprint $table): void {
            $table->id();
            $table->string('name');
            $table->text('description')->nullable();
            $productId = $table->string('product_id');
            $pricingId = $table->string('pricing_id');

            // Apply collation only for MySQL
            if (Schema::getConnection()->getDriverName() === 'mysql') {
                $productId->collation('utf8_bin');
                $pricingId->collation('utf8_bin');
            }
            $table->integer('price');
            $table->integer('mailbox_limit')->default(15);
            $table->boolean('monthly_billing')->default(true);
            $table->longText('details')->nullable();
            $table->timestamps();
        });
    }

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