<?php

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

/**
 * Generic per-business key/value settings for the BMS module (visit-calendar
 * config, notification matrix, AI knowledge-base flags, defaults…). One row
 * per (business_id, key).
 */
return new class extends Migration {
    public function up(): void
    {
        if (! Schema::hasTable('bms_settings')) {
            Schema::create('bms_settings', function (Blueprint $t) {
                $t->bigIncrements('id');
                $t->unsignedInteger('business_id');
                $t->string('key', 100);
                $t->longText('value')->nullable();
                $t->timestamps();
                $t->unique(['business_id', 'key']);
            });
        }
    }

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