<?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::disableForeignKeyConstraints();

        Schema::create('news_paragraphs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('news_id')->references('id')->on('news')->comment("關聯文章");
            $table->unsignedTinyInteger('paragraph_type')->comment('段落類型 1.images 2.text');
            $table->json('text_content')->nullable()->comment("文字段落");
            $table->string('img_url')->nullable()->comment("圖片網址");
            $table->json('img_alt')->nullable()->comment("圖片註釋");
            $table->unsignedInteger('order')->default(0)->comment("排序");
        });
        Schema::enableForeignKeyConstraints();
    }

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