<?php

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

class CreateVaiSettingsTable extends Migration
{
    public function up()
    {
        if (Schema::hasTable('vai_settings')) return;

        Schema::create('vai_settings', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('business_id')->unique();
            $table->string('provider', 20)->default('anthropic'); // anthropic | openai | gemini
            $table->text('api_key')->nullable();                   // stored encrypted via the model cast
            $table->string('model', 100)->nullable();
            $table->boolean('enabled')->default(false);
            $table->decimal('temperature', 3, 2)->default(0.30);
            $table->unsignedInteger('max_tokens')->default(1024);
            $table->text('system_prompt')->nullable();
            $table->unsignedInteger('monthly_token_budget')->nullable();
            $table->timestamps();
        });
    }

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