<?php

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

/**
 * lab_settings — per-business key/value settings (VetClinic sync toggle,
 * clinic header text, defaults...).
 */
return new class extends Migration {
    public function up(): void
    {
        if (Schema::hasTable('lab_settings')) {
            return;
        }

        Schema::create('lab_settings', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('business_id')->index();
            $table->string('key', 60);
            $table->text('value')->nullable();
            $table->timestamps();

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

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