<?php

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

/**
 * Per-Domain PHP.ini Override.
 *
 * cPanel "MultiPHP INI Editor" muadili. Domain bazlı php.ini direktif override'ları.
 * Üretimde her domain için ayrı FPM pool conf'a `php_admin_value[key] = value` yazılır.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('php_overrides', function (Blueprint $table) {
            $table->id();

            $table->foreignId('domain_id')
                ->constrained('domains')
                ->cascadeOnUpdate()
                ->cascadeOnDelete();

            $table->string('directive', 64)->comment('memory_limit, upload_max_filesize, max_execution_time, ...');
            $table->string('value', 191);
            $table->boolean('is_admin_value')->default(false)
                ->comment('true=php_admin_value (zorla), false=php_value (override edilebilir)');

            $table->timestamps();

            $table->unique(['domain_id', 'directive']);
        });
    }

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