<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('ai_tools', function (Blueprint $table) {
            $table->id();

            $table->foreignId('category_id');
            $table->foreignId('url_to_crawl_id');

            $table->string('view_count')->default(0);

            $table->string('screenshot_img')->nullable();

            $table->boolean('is_ai_tool')->default(true);
            $table->string('tool_name');
            $table->string('slug');
            $table->string('external_url');

            $table->string('is_app_web_both');
            $table->text('tagline')->nullable();
            $table->text('summary')->nullable();
            $table->string('pricing_type');
            $table->mediumText('keyword_string')->nullable();
            $table->jsonb('qna')->nullable();
            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('categories');
            $table->foreign('url_to_crawl_id')->references('id')->on('url_to_crawls');

            $table->index('view_count');
            $table->index('slug');
        });
    }

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