<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('system_setting_revisions', function (Blueprint $table) {
            $table->id();
            $table->foreignId('system_setting_id')->constrained('system_settings')->cascadeOnDelete();
            $table->string('key', 120);
            $table->longText('old_value')->nullable();
            $table->longText('new_value')->nullable();
            $table->foreignId('changed_by')->nullable()->constrained('users')->nullOnDelete();
            $table->string('changed_ip', 45)->nullable();
            $table->text('changed_agent')->nullable();
            $table->timestamp('created_at')->useCurrent();
        });
    }

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