<?php

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

/**
 * PRC-1143 — konsolide şema: `module_settings` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('module_settings', function (Blueprint $t) {
            $t->id();
            $t->unsignedBigInteger('module_id');
            $t->string('key', 64);
            $t->text('value')->nullable();
            $t->boolean('encrypted')->default(0);
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->unique(['module_id', 'key'], 'module_settings_module_id_key_unique');
            $t->foreign('module_id', 'module_settings_module_id_foreign')->references('id')->on('modules')->onDelete('cascade');
        });
    }

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