<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (! Schema::hasTable('openai_logs')) {
            Schema::create('openai_logs', function (Blueprint $table) {
                $table->id();
                $table->integer('user_id')->index('user_id');
                $table->text('question');
                $table->text('answer');
                $table->string('request_ip');
                $table->text('user_agent');
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('openai_logs');
    }
};
