Files
ai-web/database/migrations/2026_02_11_100300_create_tools_table.php
jiangdong.cheng aa16c9f8c2
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
init
2026-02-11 17:28:36 +08:00

51 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('tools', function (Blueprint $table): void {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('source_id')->nullable()->constrained()->nullOnDelete();
$table->string('name', 160);
$table->string('slug')->unique();
$table->string('summary', 260);
$table->longText('description')->nullable();
$table->string('official_url', 2048)->nullable();
$table->string('pricing_type', 32)->default('freemium');
$table->string('platform', 64)->nullable();
$table->string('language', 64)->nullable();
$table->boolean('has_api')->default(false);
$table->string('source_level', 32)->default('unknown');
$table->timestamp('last_verified_at')->nullable();
$table->string('status', 32)->default('draft');
$table->boolean('is_stale')->default(false);
$table->text('stale_note')->nullable();
$table->foreignId('alternative_tool_id')->nullable()->constrained('tools')->nullOnDelete();
$table->string('seo_title', 180)->nullable();
$table->string('seo_description', 320)->nullable();
$table->string('h1', 180)->nullable();
$table->string('canonical_url', 2048)->nullable();
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->index(['status', 'is_stale', 'published_at']);
$table->index(['category_id', 'pricing_type']);
$table->index(['source_level', 'last_verified_at']);
$table->fullText(['name', 'summary', 'description']);
});
}
public function down(): void
{
Schema::dropIfExists('tools');
}
};