<?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
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->id();

            $table->string('title');
            $table->string('slug')->unique();
            $table->longText('desc');
            $table->smallInteger('time_to_read')->default(0);
            $table->boolean('is_featured')->default(0);
            $table->foreignId('author_id')->constrained('users')->cascadeOnDelete();
            $table->string('image')->nullable();
            $table->string('video')->nullable();
            $table->json('gallery')->nullable();
            $table->longText('excerpt')->nullable();
            $table->smallInteger('status')->nullable();
            $table->timestamp('publish_at')->nullable();
            $table->integer('views')->default(0);

            $table->string('meta_title')->nullable();
            $table->longText('meta_desc')->nullable();
            $table->longText('meta_keywords')->nullable();
            $table->foreignId('created_by')->constrained('users')->cascadeOnDelete();
            $table->foreignId('updated_by')->nullable()->constrained('users')->cascadeOnDelete();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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