<?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::table('posts', function (Blueprint $table) {
            $table->enum('status', ['draft', 'pending', 'published', 'rejected'])
                ->default('draft')->after('author_id');
            $table->foreignId('reviewed_by')->nullable()->constrained('users')->after('status');
            $table->text('rejection_reason')->nullable()->after('reviewed_by');
        });
    }

    public function down(): void
    {
        Schema::table('posts', function (Blueprint $table) {
            $table->dropColumn(['status', 'reviewed_by', 'rejection_reason']);
        });
    }
};
