<?php

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::table('articles', function (Blueprint $table) {
            $table->string('status')->default('draft')->change();
            $table->mediumText('excerpt')->nullable()->after('content');
            $table->unsignedBigInteger('primary_category_id')->nullable()->after('excerpt');
            $table->string('focus_keyword')->nullable()->after('primary_category_id');
            $table->string('robots')->nullable()->after('focus_keyword');
            $table->string('canonical_url')->nullable()->after('robots');
            $table->string('og_image')->nullable()->after('canonical_url');
            $table->unsignedInteger('seo_score')->nullable()->after('og_image');
            $table->unsignedBigInteger('wp_id')->nullable()->after('user_id');
            $table->boolean('sync_status')->default(false)->after('wp_id');
            $table->dateTime('sync_at')->nullable()->after('sync_status');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('articles', function (Blueprint $table) {
            $table->string('status')->default('draft')->change();
            $table->dropColumn('excerpt');
            $table->dropColumn('primary_category_id');
            $table->dropColumn('focus_keyword');
            $table->dropColumn('robots');
            $table->dropColumn('canonical_url');
            $table->dropColumn('og_image');
            $table->dropColumn('seo_score');
            $table->dropColumn('wp_id');
            $table->dropColumn('sync_status');
            $table->dropColumn('sync_at');
        });
    }
};
