<?php

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

return new class extends Migration
{
    /**
     * Tabel setting aplikasi (key/value). Nilai secret (API key, password SMTP)
     * disimpan terenkripsi di kolom value + flag is_secret.
     */
    public function up(): void
    {
        Schema::create('settings', function (Blueprint $table) {
            $table->id();
            $table->string('key', 120)->unique();   // dot-notation config path (mis. ads.default_rate)
            $table->json('value')->nullable();       // nilai ter-enkripsi utk secret, plain utk umum
            $table->boolean('is_secret')->default(false);
            $table->timestamps();
        });
    }

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