<?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('posts', function (Blueprint $t) { $t->id(); $t->enum('type', ['announcement','kb_article','blog_post']); $t->string('subtype', 255)->nullable(); $t->enum('status', ['draft','published','archived'])->default('draft'); $t->string('title', 255); $t->string('slug', 255); $t->longText('content'); $t->text('excerpt')->nullable(); $t->string('featured_image', 255)->nullable(); $t->string('meta_title', 255)->nullable(); $t->text('meta_description')->nullable(); $t->text('meta_keywords')->nullable(); $t->boolean('is_featured')->default(0); $t->unsignedInteger('view_count')->default(0); $t->integer('sort_order')->default(0); $t->timestamp('published_at')->nullable(); $t->unsignedBigInteger('author_id')->nullable(); $t->timestamp('created_at')->nullable(); $t->timestamp('updated_at')->nullable(); $t->index('author_id', 'posts_author_id_index'); $t->index(['type', 'is_featured'], 'posts_type_is_featured_index'); $t->unique(['type', 'slug'], 'posts_type_slug_unique'); $t->index(['type', 'status', 'published_at'], 'posts_type_status_published_at_index'); $t->foreign('author_id', 'posts_author_id_foreign')->references('id')->on('admins')->onDelete('set null'); }); } public function down(): void { Schema::dropIfExists('posts'); } }; 