<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * item_sections.page_id nullable 변경
 *
 * 목적: 섹션 템플릿(is_template=true)은 특정 페이지에 속하지 않으므로
 *       page_id가 null일 수 있어야 함
 */
return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('item_sections', function (Blueprint $table) {
            $table->unsignedBigInteger('page_id')->nullable()->comment('페이지 ID (템플릿은 null)')->change();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('item_sections', function (Blueprint $table) {
            $table->unsignedBigInteger('page_id')->nullable(false)->comment('페이지 ID')->change();
        });
    }
};
