Files
cloud-chip.cn/database/migrations/2026_08_01_000005_create_articles_table.php
T
2026-08-08 18:27:38 +08:00

34 lines
1.0 KiB
PHP

<?php
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) {
$table->id();
$table->unsignedBigInteger('category_id')->nullable();
$table->string('title');
$table->string('slug')->unique();
$table->string('summary')->nullable();
$table->text('body')->nullable();
$table->string('cover')->nullable();
$table->string('author')->nullable();
$table->string('status')->default('published'); // published | draft
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('set null');
});
}
public function down(): void
{
Schema::dropIfExists('articles');
}
};