<?php

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

/**
 * Adds base_url to support the "openai_compatible" provider — any
 * OpenAI-API-compatible endpoint: DeepSeek, Groq, OpenRouter, local Ollama, etc.
 */
class AddBaseUrlToVaiSettings extends Migration
{
    public function up()
    {
        if (Schema::hasTable('vai_settings') && !Schema::hasColumn('vai_settings', 'base_url')) {
            Schema::table('vai_settings', function (Blueprint $table) {
                $table->string('base_url', 255)->nullable()->after('provider');
            });
        }
    }

    public function down()
    {
        if (Schema::hasColumn('vai_settings', 'base_url')) {
            Schema::table('vai_settings', function (Blueprint $table) {
                $table->dropColumn('base_url');
            });
        }
    }
}
