<?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_configs', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('store_id')->nullable()->comment('NULL=全局配置');
            $table->string('group', 50)->default('general')->comment('配置分组');
            $table->string('key', 100)->comment('配置键');
            $table->text('value')->nullable()->comment('配置值');
            $table->string('description', 255)->nullable();
            $table->timestamps();

            $table->unique(['store_id', 'key']);
        });
    }

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