Files
ai-web/database/migrations/2026_02_11_100500_create_articles_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

46 lines
1.7 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('articles', function (Blueprint $table): void {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('source_id')->nullable()->constrained()->nullOnDelete();
$table->string('title', 200);
$table->string('slug')->unique();
$table->string('excerpt', 320);
$table->longText('body');
$table->string('source_name', 160)->nullable();
$table->string('source_url', 2048)->nullable();
$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->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', 'published_at']);
$table->index(['is_stale', 'last_verified_at']);
$table->fullText(['title', 'excerpt', 'body']);
});
}
public function down(): void
{
Schema::dropIfExists('articles');
}
};